All tests are now passing. Huzzah.
[openmx:openmx.git] / demo / SimpleRegression_MatrixRaw.R
1 require(OpenMx)\r
2
3 data(myRegDataRaw)\r
4 \r
5 SimpleDataRaw<-myRegDataRaw[,c("x","y")]\r
6 \r
7 uniRegModel<-mxModel("Simple Regression - Matrix Specification", \r
8     mxData(\r
9         observed=SimpleDataRaw,\r
10         type="raw"),\r
11     mxMatrix(\r
12         type="Full", \r
13         nrow=2, \r
14         ncol=2,\r
15         free=c(F, F,\r
16                T, F),\r
17         values=c(0, 0,\r
18                  1, 0),\r
19         labels=c(NA,     NA,\r
20                 "beta1", NA),\r
21         byrow=TRUE,\r
22         name="A"\r
23     ),\r
24     mxMatrix(\r
25         type="Symm", \r
26         nrow=2, \r
27         ncol=2, \r
28         values=c(1, 0,\r
29                  0, 1),\r
30         free=c(T, F,\r
31                F, T),\r
32         labels=c("varx", NA,\r
33                   NA,    "residual"),\r
34         byrow=TRUE,\r
35         name="S"\r
36     ),\r
37     mxMatrix(\r
38         type="Iden",  \r
39         nrow=2, \r
40         ncol=2,\r
41         dimnames=list(c("x","y"),c("x","y")),\r
42         name="F"\r
43     ),\r
44     mxMatrix(\r
45         type="Full", \r
46         nrow=1, \r
47         ncol=2,\r
48         free=c(T, T),\r
49         values=c(0, 0),\r
50         labels=c("meanx", "beta0"),\r
51         dimnames=list(NULL,c("x","y")),\r
52         name="M"),\r
53     mxRAMObjective("A", "S", "F", "M")\r
54 )\r
55       \r
56 uniRegOutput<-mxRun(uniRegModel)\r
57 \r
58 uniRegOutput@output\r
59 \r
60 # Old Mx Output\r
61 omxCheckCloseEnough(uniRegOutput@output$estimate[["beta0"]], 2.5478, 0.001)\r
62 omxCheckCloseEnough(uniRegOutput@output$estimate[["beta1"]], 0.4831, 0.001)\r
63 omxCheckCloseEnough(uniRegOutput@output$estimate[["residual"]], 0.6652, 0.001)\r
64 omxCheckCloseEnough(uniRegOutput@output$estimate[["meanx"]], 0.0542, 0.001)\r
65 omxCheckCloseEnough(uniRegOutput@output$estimate[["varx"]], 1.1053, 0.001)\r
66 \r
67 # omxCheckCloseEnough(uniRegOutput@output$estimate[["beta0"]], 2.54776, 0.001)\r
68 # omxCheckCloseEnough(uniRegOutput@output$estimate[["beta1"]], 0.48312, 0.001)\r
69 # omxCheckCloseEnough(uniRegOutput@output$estimate[["residual"]], 0.672, 0.001)\r
70 # omxCheckCloseEnough(uniRegOutput@output$estimate[["meanx"]], 0.05412, 0.001)\r
71 # omxCheckCloseEnough(uniRegOutput@output$estimate[["varx"]], 1.11654, 0.001)\r