Description Usage Arguments Details Value Author(s) Examples
Interfaces to sem
functions that can be used
in a pipeline implemented by magrittr
.
1 2 3 |
data |
data frame, tibble, list, ... |
... |
Other arguments passed to the corresponding interfaced function. |
Interfaces call their corresponding interfaced function.
Object returned by interfaced function.
Roberto Bertolusso
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | ## Not run:
library(intubate)
library(magrittr)
library(sem)
## ntbt_rawMoments: Compute Raw Moments Matrix
## Original function to interface
rawMoments(~ Q + P + D + F + A, data = Kmenta)
## The interface puts data as first parameter
ntbt_rawMoments(Kmenta, ~ Q + P + D + F + A)
## so it can be used easily in a pipeline.
Kmenta %>%
ntbt_rawMoments(~ Q + P + D + F + A)
## ntbt_sem: General Structural Equation Models
## NOTE: this example is NOT using the formula interface.
## It is creating a list with the variables.
R.DHP <- readMoments(diag=FALSE, names=c("ROccAsp", "REdAsp", "FOccAsp",
"FEdAsp", "RParAsp", "RIQ", "RSES", "FSES", "FIQ", "FParAsp"),
text="
.6247
.3269 .3669
.4216 .3275 .6404
.2137 .2742 .1124 .0839
.4105 .4043 .2903 .2598 .1839
.3240 .4047 .3054 .2786 .0489 .2220
.2930 .2407 .4105 .3607 .0186 .1861 .2707
.2995 .2863 .5191 .5007 .0782 .3355 .2302 .2950
.0760 .0702 .2784 .1988 .1147 .1021 .0931 -.0438 .2087
")
model.dhp.1 <- specifyEquations(covs="RGenAsp, FGenAsp", text="
RGenAsp = gam11*RParAsp + gam12*RIQ + gam13*RSES + gam14*FSES + beta12*FGenAsp
FGenAsp = gam23*RSES + gam24*FSES + gam25*FIQ + gam26*FParAsp + beta21*RGenAsp
ROccAsp = 1*RGenAsp
REdAsp = lam21(1)*RGenAsp # to illustrate setting start values
FOccAsp = 1*FGenAsp
FEdAsp = lam42(1)*FGenAsp
")
dta <- list(R.DHP = R.DHP, model.dhp.1 = model.dhp.1)
rm(R.DHP, model.dhp.1)
## Original function to interface
attach(dta)
sem.dhp.1 <- ntbt_sem(model.dhp.1, R.DHP, 329,
fixed.x=c('RParAsp', 'RIQ', 'RSES', 'FSES', 'FIQ', 'FParAsp'))
summary(sem.dhp.1)
detach()
## The interface puts data as first parameter
sem.dhp.1 <- ntbt_sem(dta, model.dhp.1, R.DHP, 329,
fixed.x=c('RParAsp', 'RIQ', 'RSES', 'FSES', 'FIQ', 'FParAsp'))
summary(sem.dhp.1)
## so it can be used easily in a pipeline.
dta %>%
ntbt_sem(model.dhp.1, R.DHP, 329,
fixed.x=c('RParAsp', 'RIQ', 'RSES', 'FSES', 'FIQ', 'FParAsp')) %>%
summary()
## ntbt_tsls: Two-Stage Least Squares
## Original function to interface
tsls(Q ~ P + D, ~ D + F + A, data = Kmenta)
## The interface puts data as first parameter
ntbt_tsls(Kmenta, Q ~ P + D, ~ D + F + A)
## so it can be used easily in a pipeline.
Kmenta %>%
ntbt_tsls(Q ~ P + D, ~ D + F + A)
## End(Not run)
|
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Raw Moments
Intercept Q P D F A
Intercept 1.0000 100.8982 100.0191 97.535 96.625 10.500
Q 100.8982 10193.8525 10093.8167 9873.665 9780.155 1062.599
P 100.0191 10093.8167 10037.1729 9793.092 9651.145 1050.194
D 97.5350 9873.6647 9793.0919 9646.038 9494.644 1045.960
F 96.6250 9780.1547 9651.1453 9494.644 9489.828 994.060
A 10.5000 1062.5988 1050.1941 1045.960 994.060 143.500
N = 20
Raw Moments
Intercept Q P D F A
Intercept 1.0000 100.8982 100.0191 97.535 96.625 10.500
Q 100.8982 10193.8525 10093.8167 9873.665 9780.155 1062.599
P 100.0191 10093.8167 10037.1729 9793.092 9651.145 1050.194
D 97.5350 9873.6647 9793.0919 9646.038 9494.644 1045.960
F 96.6250 9780.1547 9651.1453 9494.644 9489.828 994.060
A 10.5000 1062.5988 1050.1941 1045.960 994.060 143.500
N = 20
Raw Moments
Intercept Q P D F A
Intercept 1.0000 100.8982 100.0191 97.535 96.625 10.500
Q 100.8982 10193.8525 10093.8167 9873.665 9780.155 1062.599
P 100.0191 10093.8167 10037.1729 9793.092 9651.145 1050.194
D 97.5350 9873.6647 9793.0919 9646.038 9494.644 1045.960
F 96.6250 9780.1547 9651.1453 9494.644 9489.828 994.060
A 10.5000 1062.5988 1050.1941 1045.960 994.060 143.500
N = 20
Read 45 items
Read 6 items
NOTE: adding 4 variances to the model
Model Chisquare = 26.69722 Df = 15 Pr(>Chisq) = 0.03130238
AIC = 64.69722
BIC = -60.24365
Normalized Residuals
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.79953 -0.11783 0.00000 -0.01201 0.03974 1.56525
R-square for Endogenous Variables
RGenAsp FGenAsp ROccAsp REdAsp FOccAsp FEdAsp
0.5220 0.6170 0.5879 0.6639 0.6888 0.5954
Parameter Estimates
Estimate Std Error z value Pr(>|z|)
gam11 0.16122238 0.03879229 4.1560415 3.238091e-05
gam12 0.24964951 0.04398093 5.6763131 1.376288e-08
gam13 0.21840339 0.04419737 4.9415476 7.750487e-07
gam14 0.07183929 0.04970696 1.4452563 1.483859e-01
beta12 0.18423232 0.09488787 1.9415793 5.218805e-02
gam23 0.06188691 0.05171968 1.1965835 2.314690e-01
gam24 0.22886711 0.04416218 5.1824232 2.190216e-07
gam25 0.34903540 0.04528979 7.7067130 1.290997e-14
gam26 0.15953413 0.03882593 4.1089578 3.974486e-05
beta21 0.23547779 0.11938929 1.9723527 4.856936e-02
lam21 1.06267767 0.09013865 11.7893677 4.428532e-32
lam42 0.92972555 0.07028108 13.2286752 5.993451e-40
V[RGenAsp] 0.28098694 0.04623153 6.0778199 1.218274e-09
C[RGenAsp,FGenAsp] -0.02260935 0.05119391 -0.4416413 6.587488e-01
V[FGenAsp] 0.26383537 0.04466688 5.9067334 3.489577e-09
V[ROccAsp] 0.41214523 0.05122464 8.0458399 8.565593e-16
V[REdAsp] 0.33614544 0.05209991 6.4519386 1.104283e-10
V[FOccAsp] 0.31119476 0.04592712 6.7758385 1.236868e-11
V[FEdAsp] 0.40460387 0.04618438 8.7606206 1.941783e-18
gam11 RGenAsp <--- RParAsp
gam12 RGenAsp <--- RIQ
gam13 RGenAsp <--- RSES
gam14 RGenAsp <--- FSES
beta12 RGenAsp <--- FGenAsp
gam23 FGenAsp <--- RSES
gam24 FGenAsp <--- FSES
gam25 FGenAsp <--- FIQ
gam26 FGenAsp <--- FParAsp
beta21 FGenAsp <--- RGenAsp
lam21 REdAsp <--- RGenAsp
lam42 FEdAsp <--- FGenAsp
V[RGenAsp] RGenAsp <--> RGenAsp
C[RGenAsp,FGenAsp] FGenAsp <--> RGenAsp
V[FGenAsp] FGenAsp <--> FGenAsp
V[ROccAsp] ROccAsp <--> ROccAsp
V[REdAsp] REdAsp <--> REdAsp
V[FOccAsp] FOccAsp <--> FOccAsp
V[FEdAsp] FEdAsp <--> FEdAsp
Iterations = 32
Model Chisquare = 26.69722 Df = 15 Pr(>Chisq) = 0.03130238
AIC = 64.69722
BIC = -60.24365
Normalized Residuals
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.79953 -0.11783 0.00000 -0.01201 0.03974 1.56525
R-square for Endogenous Variables
RGenAsp FGenAsp ROccAsp REdAsp FOccAsp FEdAsp
0.5220 0.6170 0.5879 0.6639 0.6888 0.5954
Parameter Estimates
Estimate Std Error z value Pr(>|z|)
gam11 0.16122238 0.03879229 4.1560415 3.238091e-05
gam12 0.24964951 0.04398093 5.6763131 1.376288e-08
gam13 0.21840339 0.04419737 4.9415476 7.750487e-07
gam14 0.07183929 0.04970696 1.4452563 1.483859e-01
beta12 0.18423232 0.09488787 1.9415793 5.218805e-02
gam23 0.06188691 0.05171968 1.1965835 2.314690e-01
gam24 0.22886711 0.04416218 5.1824232 2.190216e-07
gam25 0.34903540 0.04528979 7.7067130 1.290997e-14
gam26 0.15953413 0.03882593 4.1089578 3.974486e-05
beta21 0.23547779 0.11938929 1.9723527 4.856936e-02
lam21 1.06267767 0.09013865 11.7893677 4.428532e-32
lam42 0.92972555 0.07028108 13.2286752 5.993451e-40
V[RGenAsp] 0.28098694 0.04623153 6.0778199 1.218274e-09
C[RGenAsp,FGenAsp] -0.02260935 0.05119391 -0.4416413 6.587488e-01
V[FGenAsp] 0.26383537 0.04466688 5.9067334 3.489577e-09
V[ROccAsp] 0.41214523 0.05122464 8.0458399 8.565593e-16
V[REdAsp] 0.33614544 0.05209991 6.4519386 1.104283e-10
V[FOccAsp] 0.31119476 0.04592712 6.7758385 1.236868e-11
V[FEdAsp] 0.40460387 0.04618438 8.7606206 1.941783e-18
gam11 RGenAsp <--- RParAsp
gam12 RGenAsp <--- RIQ
gam13 RGenAsp <--- RSES
gam14 RGenAsp <--- FSES
beta12 RGenAsp <--- FGenAsp
gam23 FGenAsp <--- RSES
gam24 FGenAsp <--- FSES
gam25 FGenAsp <--- FIQ
gam26 FGenAsp <--- FParAsp
beta21 FGenAsp <--- RGenAsp
lam21 REdAsp <--- RGenAsp
lam42 FEdAsp <--- FGenAsp
V[RGenAsp] RGenAsp <--> RGenAsp
C[RGenAsp,FGenAsp] FGenAsp <--> RGenAsp
V[FGenAsp] FGenAsp <--> FGenAsp
V[ROccAsp] ROccAsp <--> ROccAsp
V[REdAsp] REdAsp <--> REdAsp
V[FOccAsp] FOccAsp <--> FOccAsp
V[FEdAsp] FEdAsp <--> FEdAsp
Iterations = 32
Model Chisquare = 26.69722 Df = 15 Pr(>Chisq) = 0.03130238
AIC = 64.69722
BIC = -60.24365
Normalized Residuals
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.79953 -0.11783 0.00000 -0.01201 0.03974 1.56525
R-square for Endogenous Variables
RGenAsp FGenAsp ROccAsp REdAsp FOccAsp FEdAsp
0.5220 0.6170 0.5879 0.6639 0.6888 0.5954
Parameter Estimates
Estimate Std Error z value Pr(>|z|)
gam11 0.16122238 0.03879229 4.1560415 3.238091e-05
gam12 0.24964951 0.04398093 5.6763131 1.376288e-08
gam13 0.21840339 0.04419737 4.9415476 7.750487e-07
gam14 0.07183929 0.04970696 1.4452563 1.483859e-01
beta12 0.18423232 0.09488787 1.9415793 5.218805e-02
gam23 0.06188691 0.05171968 1.1965835 2.314690e-01
gam24 0.22886711 0.04416218 5.1824232 2.190216e-07
gam25 0.34903540 0.04528979 7.7067130 1.290997e-14
gam26 0.15953413 0.03882593 4.1089578 3.974486e-05
beta21 0.23547779 0.11938929 1.9723527 4.856936e-02
lam21 1.06267767 0.09013865 11.7893677 4.428532e-32
lam42 0.92972555 0.07028108 13.2286752 5.993451e-40
V[RGenAsp] 0.28098694 0.04623153 6.0778199 1.218274e-09
C[RGenAsp,FGenAsp] -0.02260935 0.05119391 -0.4416413 6.587488e-01
V[FGenAsp] 0.26383537 0.04466688 5.9067334 3.489577e-09
V[ROccAsp] 0.41214523 0.05122464 8.0458399 8.565593e-16
V[REdAsp] 0.33614544 0.05209991 6.4519386 1.104283e-10
V[FOccAsp] 0.31119476 0.04592712 6.7758385 1.236868e-11
V[FEdAsp] 0.40460387 0.04618438 8.7606206 1.941783e-18
gam11 RGenAsp <--- RParAsp
gam12 RGenAsp <--- RIQ
gam13 RGenAsp <--- RSES
gam14 RGenAsp <--- FSES
beta12 RGenAsp <--- FGenAsp
gam23 FGenAsp <--- RSES
gam24 FGenAsp <--- FSES
gam25 FGenAsp <--- FIQ
gam26 FGenAsp <--- FParAsp
beta21 FGenAsp <--- RGenAsp
lam21 REdAsp <--- RGenAsp
lam42 FEdAsp <--- FGenAsp
V[RGenAsp] RGenAsp <--> RGenAsp
C[RGenAsp,FGenAsp] FGenAsp <--> RGenAsp
V[FGenAsp] FGenAsp <--> FGenAsp
V[ROccAsp] ROccAsp <--> ROccAsp
V[REdAsp] REdAsp <--> REdAsp
V[FOccAsp] FOccAsp <--> FOccAsp
V[FEdAsp] FEdAsp <--> FEdAsp
Iterations = 32
Model Formula: Q ~ P + D
Instruments: ~D + F + A
Coefficients:
(Intercept) P D
94.6333039 -0.2435565 0.3139918
Model Formula: Q ~ P + D
Instruments: ~D + F + A
Coefficients:
(Intercept) P D
94.6333039 -0.2435565 0.3139918
Model Formula: Q ~ P + D
<environment: 0x5628a150fbe8>
Instruments: ~D + F + A
<environment: 0x5628a150fbe8>
Coefficients:
(Intercept) P D
94.6333039 -0.2435565 0.3139918
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.