Contents
- Draw a scatter plot of boxoffice towards rating, grouped by score
- Create dataset array, convert score to a nominal array
- Queston 1 in Matlab
- Query 2 in Matlab
- Questions three in Matlab
- 20/20
% Apply of Regression with categorical covariates
% By Segovia on 01/03/2014
clear;clc;shut;
load MovieData.mat
Draw a scatter plot of boxoffice towards rating, grouped by score
determine();
gscatter(rating,boxoffice, score,'bgr','x.o^');
title('boxoffice vs. rating, grouped by score')
Create dataset array, convert score to a nominal array
Film=dataset(boxoffice, rating,score);
Film.score=nominal(Film.score);
Queston 1 in Matlab
%Match a regression mannequin
% in 2013a model, use perform LinearModel.match
% in 2013b model, use perform fitlm
match=LinearModel.match(Film, 'rating~score')
match =
Linear regression mannequin:
rating ~ 1 + score
Estimated Coefficients:
Estimate SE tStat pValue
(Intercept) sixty seven.sixty five 7.1933 9.4046 1.7256e-sixteen
rating_PG -12.593 7.8486 -1.6045 zero.11093
rating_PG-thirteen -eleven.815 7.4113 -1.5941 zero.11323
rating_R -12.02 7.4755 -1.6079 zero.11017
Variety of observations: one hundred forty, Error levels of freedom: 136
Root Imply Squared Error: 14.four
R-squared: zero.0199, Adjusted R-Squared -zero.00177
F-statistic vs. fixed mannequin: zero.918, p-worth = zero.434
Query 2 in Matlab
%Match a regression mannequin and use "R" as reference degree in score
Movie2=Film;
Movie2.score=reorderlevels(Movie2.score, 'R','G','PG','PG-thirteen');
fit2=LinearModel.match(Movie2,'rating~score')
fit2 =
Linear regression mannequin:
rating ~ 1 + score
Estimated Coefficients:
Estimate SE tStat pValue
(Intercept) fifty five.sixty three 2.0346 27.342 four.0302e-fifty seven
rating_G 12.02 7.4755 1.6079 zero.11017
rating_PG -zero.57286 three.7411 -zero.15313 zero.87852
rating_PG-thirteen zero.20538 2.7062 zero.075893 zero.93962
Variety of observations: one hundred forty, Error levels of freedom: 136
Root Imply Squared Error: 14.four
R-squared: zero.0199, Adjusted R-Squared -zero.00177
F-statistic vs. fixed mannequin: zero.918, p-worth = zero.434
Questions three in Matlab
anova(match)
ans =
SumSq DF MeanSq F pValue
score 570.12 three one hundred ninety.04 zero.91818 zero.43398
Error 28149 136 206.ninety eight
20/20
[~,~,st]=anova1(Movie2.rating, Movie2.score,'off');
[c,m,h,nms]=multcompare(st,'show','off','ctype','hsd')
c =
1.0000 2.0000 -31.2248 -12.0200 7.1848
1.0000 three.0000 -9.0380 zero.5729 10.1837
1.0000 four.0000 -7.1578 -zero.2054 6.7470
2.0000 three.0000 -7.5703 12.5929 32.7560
2.0000 four.0000 -7.2254 eleven.8146 30.8546
three.0000 four.0000 -10.0553 -zero.7782 eight.4988
m =
fifty five.6300 2.0346
sixty seven.6500 7.1933
fifty five.0571 three.1394
fifty five.8354 1.7844
h =
[]
nms =
'R'
'G'
'PG'
'PG-thirteen'
Revealed with MATLAB® R2013a
No comments:
Post a Comment