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