Description Usage Arguments Value References Examples
Estimates dispositional trait using the SOFA approach from Franco & Laros (in preparation).
1 | SOFA(x, y, method="bayes")
|
x |
A vector of a situational predictor variable. |
y |
A vector of a behavioral criterion variable. |
method |
A string with the method to be used for estimating the dispositional true scores. Use "bayes" for the Bayesian model, "gam" for the GAM model, "kernel" for the Kernel model, and "loess" for the Loess model. Defaults to the Bayesian model. |
A list containing the following components:
disposition |
The estimates of the dispositional trait. |
full |
The full set of results returned by each method. |
pred |
The estimates of the behavioral criterion variable. |
If any of the Maximum-Likelihood methods is used (gam, kernell, or loess), then BIC is returned:
bic |
The BIC fit index for the model. |
If the Bayesian model is used, then DIC is returned:
dic |
The DIC fit index for the model. |
Franco, V.R., & Laros, J.A. (in preparation). "An operationalization of Lewin's Equation: The situational optimization function analysis". Unsubmitted.
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 | ### Data generation
## Uncorrelated x, v, and u
mu <- rep(0,3)
set.seed(seed)
rho <- 0
Sigma <- matrix(c(1,0,rho,
0,1,0,
rho,0,1),
nrow=3, ncol=3)
z <- MASS::mvrnorm(n=n, mu=mu, Sigma=Sigma, empirical=T)
Z <- pnorm(z)
x <- qnorm(Z[,1]) # Observations
v <- qnorm(Z[,2]) # Stochastic error
u <- truncnorm::qtruncnorm(Z[,3],a=0,b=Inf,0, # Efficiency
max(x) - min(x))
## Cost frontier
fy <- 1.5 ^ (x)
y <- fy + v + u
### Estimation
M1 <- SOFA(x,y,method="bayes")
M2 <- SOFA(x,y,method="gam")
M3 <- SOFA(x,y,method="kernel")
M4 <- SOFA(x,y,method="loess")
## Compare results
cor(data.frame("Bayesian"= M1$disposition),
"GAM" = M2$disposition),
"Kernel" = M3$disposition),
"Loess" = M4$disposition))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.