SOFA: Situational Optimization Function Analysis

Description Usage Arguments Value References Examples

View source: R/SOFA.R

Description

Estimates dispositional trait using the SOFA approach from Franco & Laros (in preparation).

Usage

1
SOFA(x, y, method="bayes")

Arguments

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.

Value

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.

References

Franco, V.R., & Laros, J.A. (in preparation). "An operationalization of Lewin's Equation: The situational optimization function analysis". Unsubmitted.

Examples

 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))

vthorrf/psysofa documentation built on March 10, 2021, 10:12 a.m.