Question: How to use Maximum Likelyhood Estimator (MLE) in MaplaTA

Our students use R for solving digital questions about Multivariate Statistics made with MapleTA.

How to use a MLE in MapleTA. Below the code I used in a question?

Remaks about how to program this better or more easy are more than welcome.

://noise. In Dutch ruis means noise;
$ruislow=range(1,5,1);
$ruishigh=range(6,9,1);
://data 1;
$x1=10+rand($ruislow,$ruishigh,1);
$x2=30+rand($ruislow,$ruishigh,1);
$x3=50+rand($ruislow,$ruishigh,1);
$x4=70+rand($ruislow,$ruishigh,1);
$x5=90+rand($ruislow,$ruishigh,1);
$x6=125+rand($ruislow,$ruishigh,1);
$x7=175+rand($ruislow,$ruishigh,1);
$X=maple("Vector([$x1,$x2,$x3,$x4,$x5,$x6,$x7])");
$displayX=maple("printf(MathML:-ExportPresentation($X))");
$TX=maple("LinearAlgebra[Transpose]($X)");
$displayTX=maple("printf(MathML:-ExportPresentation($TX))");
://data 2;
$y1=4+rand($ruislow,$ruishigh,1);
$y2=12+rand($ruislow,$ruishigh,1);
$y3=32+rand($ruislow,$ruishigh,1);
$y4=36+rand($ruislow,$ruishigh,1);
$y5=42+rand($ruislow,$ruishigh,1);
$y6=36+rand($ruislow,$ruishigh,1);
$y7=19+rand($ruislow,$ruishigh,1);
$Y=maple("Vector([$y1,$y2,$y3,$y4,$y5,$y6,$y7])");
$displayY=maple("printf(MathML:-ExportPresentation($Y))");
$TY=maple("LinearAlgebra[Transpose]($Y)");
$displayTY=maple("printf(MathML:-ExportPresentation($TY))");
://data 3;
$z1=76+rand($ruislow,$ruishigh,1);
$z2=108+rand($ruislow,$ruishigh,1);
$z3=128+rand($ruislow,$ruishigh,1);
$z4=54+rand($ruislow,$ruishigh,1);
$z5=18+rand($ruislow,$ruishigh,1);
$z6=4+rand($ruislow,$ruishigh,1);
$z7=1+rand($ruislow,$ruishigh,1);
$Z=maple("Vector([$z1,$z2,$z3,$z4,$z5,$z6,$z7])");
$displayZ=maple("printf(MathML:-ExportPresentation($Z))");
$TZ=maple("LinearAlgebra[Transpose]($Z)");
$displayTZ=maple("printf(MathML:-ExportPresentation($TZ))");
://totals;
$t1=$y1+$z1;
$t2=$y2+$z2;
$t3=$y3+$z3;
$t4=$y4+$z4;
$t5=$y5+$z5;
$t6=$y6+$z6;
$t7=$y7+$z7;
$T=maple("Vector([$t1,$t2,$t3,$t4,$t5,$t6,$t7])");
$displayT=maple("printf(MathML:-ExportPresentation($T))");
:// percentage Y;
$py1=$y1/$t1;
$py2=$y2/$t2;
$py3=$y3/$t3;
$py4=$y4/$t4;
$py5=$y5/$t5;
$py6=$y6/$t6;
$py7=$y7/$t7;
:// percentage Z;
$pz1=$z1/$t1;
$pz2=$z2/$t2;
$pz3=$z3/$t3;
$pz4=$z4/$t4;
$pz5=$z5/$t5;
$pz6=$z6/$t6;
$pz7=$z7/$t7;
://odds;
$o1=$py1/$pz1;
$o2=$py2/$pz2;
$o3=$py3/$pz3;
$o4=$py4/$pz4;
$o5=$py5/$pz5;
$o6=$py6/$pz6;
$o7=$py7/$pz7;
://logit;
$ln1=ln($o1);
$ln2=ln($o2);
$ln3=ln($o3);
$ln4=ln($o4);
$ln5=ln($o5);
$ln6=ln($o6);
$ln7=ln($o7);
$L=maple("Vector([$ln1,$ln2,$ln3,$ln4,$ln5,$ln6,$ln7])");
$displayL=maple("printf(MathML:-ExportPresentation($L))");
://linreg;
://$fit1=maple("Statistics[LinearFit]([1,t],$X,$L,t)");
$fit=maple("map(rhs, Statistics[Fit](a*x+b, $X, $L, x, output=parametervalues))");
$intercept=maple("$fit[2]");
$slope=maple("$fit[1]");
$r=maple("evalf(Statistics[Correlation]($X,$L))");

Best regards,

Nico

 

Please Wait...