====== 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 ====== ###################################################### > ## data file: PlannedBehavior.csv > ###################################################### > df <- read.csv("http://commres.net/wiki/_media/r/plannedbehavior.csv") > head(df) attitude norms control intention behavior 1 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 ====== Model 2 ====== # Specify model specmod2 <- " intention ~ attitude + norms + control attitude ~~ norms + control norms ~~ control " # Estimate model fitmod2 <- sem(specmod2, data=df) # Summarize model summary(fitmod2, fit.measures=TRUE, rsquare=TRUE) fitmod <- lm(intention ~ attitude + norms + control, data=df) summary(fitmod) > # Specify model > specmod2 <- " + intention ~ attitude + norms + control + attitude ~~ norms + control + norms ~~ control + " > # Estimate model > fitmod2 <- sem(specmod2, data=df) > > # Summarize model > summary(fitmod2, fit.measures=TRUE, rsquare=TRUE) lavaan 0.6-9 ended normally after 17 iterations Estimator ML Optimization method NLMINB Number of model parameters 10 Number of observations 199 Model Test User Model: Test statistic 0.000 Degrees of freedom 0 Model Test Baseline Model: Test statistic 136.306 Degrees of freedom 6 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) -1011.828 Loglikelihood unrestricted model (H1) -1011.828 Akaike (AIC) 2043.656 Bayesian (BIC) 2076.589 Sample-size adjusted Bayesian (BIC) 2044.908 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 Covariances: Estimate Std.Err z-value P(>|z|) attitude ~~ norms 0.200 0.064 3.128 0.002 control 0.334 0.070 4.748 0.000 norms ~~ control 0.220 0.065 3.411 0.001 Variances: Estimate Std.Err z-value P(>|z|) .intention 0.530 0.053 9.975 0.000 attitude 0.928 0.093 9.975 0.000 norms 0.830 0.083 9.975 0.000 control 0.939 0.094 9.975 0.000 R-Square: Estimate intention 0.369 > > fitmod <- lm(intention ~ attitude + norms + control, data=df) > summary(fitmod) Call: lm(formula = intention ~ attitude + norms + control, data = df) Residuals: Min 1Q Median 3Q Max -1.80282 -0.52734 -0.06018 0.51228 1.85202 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.58579 0.23963 2.445 0.0154 * attitude 0.35232 0.05866 6.006 9.13e-09 *** norms 0.15250 0.05979 2.550 0.0115 * control 0.27502 0.05862 4.692 5.09e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.7356 on 195 degrees of freedom Multiple R-squared: 0.369, Adjusted R-squared: 0.3593 F-statistic: 38.01 on 3 and 195 DF, p-value: < 2.2e-16 > ====== Model 3 ====== # Specify model specmod3 <- " # directional relationships intention ~ attitude + norms + control behavior ~ intention # covariances attitude ~~ norms + control norms ~~ control " # Estimate model fitmod3 <- sem(specmod3, data=df) # Summarize model summary(fitmod3, fit.measures=TRUE, rsquare=TRUE) > df <- read.csv("http://commres.net/wiki/_media/r/plannedbehavior.csv") > # Specify model > specmod3 <- " + # directional relationships + intention ~ attitude + norms + control + behavior ~ intention + + # covariances + attitude ~~ norms + control + norms ~~ control + " > # Estimate model > fitmod3 <- sem(specmod3, data=df) > > # Summarize model > summary(fitmod3, fit.measures=TRUE, rsquare=TRUE) lavaan 0.6-12 ended normally after 18 iterations Estimator ML Optimization method NLMINB Number of model parameters 12 Number of observations 199 Model Test User Model: Test statistic 2.023 Degrees of freedom 3 P-value (Chi-square) 0.568 Model Test Baseline Model: Test statistic 182.295 Degrees of freedom 10 P-value 0.000 User Model versus Baseline Model: Comparative Fit Index (CFI) 1.000 Tucker-Lewis Index (TLI) 1.019 Loglikelihood and Information Criteria: Loglikelihood user model (H0) -1258.517 Loglikelihood unrestricted model (H1) -1257.506 Akaike (AIC) 2541.035 Bayesian (BIC) 2580.555 Sample-size adjusted Bayesian (BIC) 2542.538 Root Mean Square Error of Approximation: RMSEA 0.000 90 Percent confidence interval - lower 0.000 90 Percent confidence interval - upper 0.103 P-value RMSEA <= 0.05 0.735 Standardized Root Mean Square Residual: SRMR 0.019 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 behavior ~ intention 0.453 0.065 7.014 0.000 Covariances: Estimate Std.Err z-value P(>|z|) attitude ~~ norms 0.200 0.064 3.128 0.002 control 0.334 0.070 4.748 0.000 norms ~~ control 0.220 0.065 3.411 0.001 Variances: Estimate Std.Err z-value P(>|z|) .intention 0.530 0.053 9.975 0.000 .behavior 0.699 0.070 9.975 0.000 attitude 0.928 0.093 9.975 0.000 norms 0.830 0.083 9.975 0.000 control 0.939 0.094 9.975 0.000 R-Square: Estimate intention 0.369 behavior 0.198 a <- (5*(5+1))/2 b <- 12 a-b