This is an old revision of the document!
Table of Contents
Path Analysis
Planned Behavior Modeling
###################################################### ## data file: PlannedBehavior.csv ###################################################### df <- read.csv("http://commres.net/wiki/_media/r/plannedbehavior.csv") head(df) str(df) ###################################################### # attitude # norms # control # intention # behavior ###################################################### # install.packages("lavaan") library(lavaan) # Specify model specmod <- " intention ~ attitude + norms + control " # Estimate model fitmod <- sem(specmod, data=df) # Summarize model summary(fitmod, fit.measures=TRUE, rsquare=TRUE)
Output
<coce>
######################################################
## data file: PlannedBehavior.csv
######################################################
df ← read.csv(“http://commres.net/wiki/_media/r/plannedbehavior.csv”)
head(df)attitude norms control intention behavior1 2.31 2.31 2.03 2.50 2.62
2 4.66 4.01 3.63 3.99 3.64
3 3.85 3.56 4.20 4.35 3.83
4 4.24 2.25 2.84 1.51 2.25
5 2.91 3.31 2.40 1.45 2.00
6 2.99 2.51 2.95 2.59 2.20
str(df)
'data.frame': 199 obs. of 5 variables:
$ attitude : num 2.31 4.66 3.85 4.24 2.91 2.99 3.96 3.01 4.77 3.67 …
$ norms : num 2.31 4.01 3.56 2.25 3.31 2.51 4.65 2.98 3.09 3.63 …
$ control : num 2.03 3.63 4.2 2.84 2.4 2.95 3.77 1.9 3.83 5 …
$ intention: num 2.5 3.99 4.35 1.51 1.45 2.59 4.08 2.58 4.87 3.09 …
$ behavior : num 2.62 3.64 3.83 2.25 2 2.2 4.41 4.15 4.35 3.95 …
######################################################
# attitude
# norms
# control
# intention
# behavior
######################################################
# install.packages(“lavaan”)
library(lavaan)
This is lavaan 0.6-9
lavaan is FREE software! Please report any bugs.
Warning message:
패키지 ‘lavaan’는 R 버전 4.1.2에서 작성되었습니다
# Specify model
specmod ← “
+ intention ~ attitude + norms + control
+ ”
# Estimate model
fitmod ← sem(specmod, data=df)
# Summarize model
summary(fitmod, fit.measures=TRUE, rsquare=TRUE)
lavaan 0.6-9 ended normally after 11 iterations
Estimator ML Optimization method NLMINB Number of model parameters 4 Number of observations 199
Model Test User Model:
Test statistic 0.000 Degrees of freedom 0
Model Test Baseline Model:
Test statistic 91.633 Degrees of freedom 3 P-value 0.000
User Model versus Baseline Model:
Comparative Fit Index (CFI) 1.000 Tucker-Lewis Index (TLI) 1.000
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -219.244 Loglikelihood unrestricted model (H1) -219.244 Akaike (AIC) 446.489 Bayesian (BIC) 459.662 Sample-size adjusted Bayesian (BIC) 446.990
Root Mean Square Error of Approximation:
RMSEA 0.000 90 Percent confidence interval - lower 0.000 90 Percent confidence interval - upper 0.000 P-value RMSEA <= 0.05 NA
Standardized Root Mean Square Residual:
SRMR 0.000
Parameter Estimates:
Standard errors Standard Information Expected Information saturated (h1) model Structured
Regressions:
Estimate Std.Err z-value P(>|z|) intention ~ attitude 0.352 0.058 6.068 0.000 norms 0.153 0.059 2.577 0.010 control 0.275 0.058 4.740 0.000
Variances:
Estimate Std.Err z-value P(>|z|) .intention 0.530 0.053 9.975 0.000
R-Square:
Estimate intention 0.369
</code>