Grader

A practise set

이 제출물을 팔로우합니다

V=[1 2 3 4 5 6 7 8]';
S=[31 54 83 117 142 177 202 237]';
rVS = corr(V, S);
strongPositiveAssociation = rVS > 0.95;
Sshifted = S + 100;
rShifted = corr(V, Sshifted);
correlationShiftDifference = abs(rVS - rShifted);
correlationMeaning = "strong positive linear association";
causationProven = false;
V = [1 2 3 4 5]';
S = [5.9 41.5 89.0 136.0 183.9]';
mdl = fitlm(V,S);
beta0 = mdl.Coefficients.Estimate(1);
beta1 = mdl.Coefficients.Estimate(2);
S_hat = predict(mdl,V);
residuals = S - S_hat;
SSE = sum(residuals.^2);
speedAt3p5 = predict(mdl,3.5);
voltageFor120 = (120 - beta0)/beta1;
slopeUnits = "rpm/V";
x = [0 1 2 3 4 5]';
y = [2.2 4.8 8.1 10.9 14.2 16.7]';
xbar = mean(x);
ybar = mean(y);
beta1_manual = sum((x - xbar).*(y - ybar)) / sum((x - xbar).^2);
beta0_manual = ybar - beta1_manual*xbar;
yhat_manual = beta0_manual + beta1_manual*x;
e_manual = y - yhat_manual;
SSE_manual = sum(e_manual.^2);
sumResiduals = sum(e_manual);
residualSumApproximatelyZero = abs(sumResiduals) < 1e-10;
mdl_check = fitlm(x,y);
interceptDifference = abs(beta0_manual -mdl_check.Coefficients.Estimate(1));
slopeDifference = abs(beta1_manual - mdl_check.Coefficients.Estimate(2));
Y = [12.0 18.1 24.3 31.0 37.4 44.2 50.1 57.0]';
Yhat = [11.2 18.8 25.0 30.0 37.8 43.3 51.0 56.2]';
e = Y - Yhat
SSE = sum(e.^2)
SST = sum((Y - mean(Y)).^2)
R2manual = 1 - SSE/SST
RMSE = sqrt(mean(e.^2))
Abss = abs(e)
maxAbsResidual = max(abs(e))
worstIndex = max(abs(e))
goodR2 = R2manual > 0.98
rmseBelow1 = RMSE < 1
residualAssessment = "no obvious curvature"
x=(-4:4)';
y=[17.4 10.2 5.1 2.0 1.2 2.2 5.4 10.5 17.8]';
rXY = corr(x, y)
p1 = polyfit(x, y, 1)
yhat1 = polyval(p1, x)
e1 = y - yhat1
SSE1 = sum(e1.^2)
RMSE1 = sqrt(mean(e1.^2))
SSTcurve = sum((y - mean(y)).^2)
R2linear = 1 - SSE1/SSTcurve
p2 = polyfit(x, y, 2)
yhat2 = polyval(p2, x)
e2 = y - yhat2
SSE2 = sum(e2.^2)
RMSE2 = sqrt(mean(e2.^2))
R2quadratic = 1 - SSE2/SSTcurve
rSquaredDifference = abs(R2linear - rXY^2)
rmseImprovementPercent = 100 * (RMSE1 - RMSE2) / RMSE1
linearResidualCurvature = sign(mean(e1([1 2 8 9]))) ~= sign(mean(e1([4 5 6])))
preferredModel = "quadratic"
reason = "systematic curvature in linear residuals";
yAt2p5 = polyval(p2, 2.5)
x = (-4:4)';
y = [17.4 10.2 5.1 2.0 1.2 2.2 5.4 10.5 17.8]';
mdlReduced = fitlm(x,y)
SSEreduced = sum(mdlReduced.Residuals.Raw.^2)
mdlPoly2 = fitlm(x,y,'quadratic')
SSEfull = sum(mdlPoly2.Residuals.Raw.^2)
n = length(x)
pReduced = 2
pFull = 3
df1 = pFull - pReduced
df2 = n - pFull
Fstat = ((SSEreduced - SSEfull)/df1) / (SSEfull/df2)
alpha = 0.05
Fcritical = finv(1-alpha,df1,df2)
pValue = 1 - fcdf(Fstat,df1,df2)
rejectH0_byCritical = Fstat > Fcritical
rejectH0_byPValue = pValue < alpha
if rejectH0_byPValue
decision = "reject H0"
modelConclusion = "quadratic term is statistically justified"
else
decision = "fail to reject H0"
modelConclusion = "quadratic term is not statistically justified"
end
x2 = x.^2
dataTbl = table(x,x2,y)
mdlQuad = fitlm(dataTbl,'y ~ x + x2')
tQuadratic = mdlQuad.Coefficients.tStat(3)
FtSquaredDifference = abs(Fstat - tQuadratic^2)
interpretation = "Rejecting H0 means the data provide statistically significant evidence that the quadratic coefficient differs from zero and that including the quadratic term improves model fit; it does not prove that the quadratic model is true."
V=[2 3 4 5 6 2 3 4 5 6 2 3 4 5 6]';
T=[0.05*ones(5,1);0.10*ones(5,1);0.15*ones(5,1)];
Speed=[69 108 149 188 229 61 101 140 181 219 54 92 132 172 211]';
dataTbl = table(V,T,Speed);
mdlMulti = fitlm(dataTbl,'Speed ~ V + T');
beta0 = mdlMulti.Coefficients.Estimate(1);
betaV = mdlMulti.Coefficients.Estimate(2);
betaT = mdlMulti.Coefficients.Estimate(3);
speedHat = predict(mdlMulti,dataTbl);
resMulti = Speed - speedHat;
RMSEmulti = sqrt(mean(resMulti.^2));
R2multi = mdlMulti.Rsquared.Ordinary;
newData = table(4.5,0.12,'VariableNames',{'V','T'});
speedNew = predict(mdlMulti,newData);
voltageFor150 = (150 - beta0 - betaT*0.12)/betaV;
if betaT < 0
loadEffect = "negative";
else
loadEffect = "nonnegative";
end
voltageEffectPositive = (betaV > 0);
predictionWithinRange = (voltageFor150 >= 2) && (voltageFor150 <= 6);

인용 양식

anshika (2026). Grader (https://kr.mathworks.com/matlabcentral/fileexchange/184566-grader), MATLAB Central File Exchange. 검색 날짜: .

태그

태그 추가

Add the first tag.

일반 정보

MATLAB 릴리스 호환 정보

  • 모든 릴리스와 호환

플랫폼 호환성

  • Windows
  • macOS
  • Linux
버전 퍼블리시됨 릴리스 정보 Action
1.0.0