User Tools

Site Tools


path_analysis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
path_analysis [2022/11/09 21:22] hkimscilpath_analysis [2022/11/11 08:34] (current) – [Model 3] hkimscil
Line 1: Line 1:
 ====== Path Analysis ====== ====== Path Analysis ======
 ===== Planned Behavior Modeling ===== ===== Planned Behavior Modeling =====
-<code>+<code php>
 ###################################################### ######################################################
 ## data file: PlannedBehavior.csv ## data file: PlannedBehavior.csv
Line 27: Line 27:
 # Summarize model # Summarize model
 summary(fitmod, fit.measures=TRUE, rsquare=TRUE) summary(fitmod, fit.measures=TRUE, rsquare=TRUE)
- 
- 
 </code> </code>
  
Line 140: Line 138:
                    Estimate                    Estimate
     intention         0.369     intention         0.369
 +</code>
 +
 +====== Model 2 ======
 +<code>
 +# 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)
 +</code>
 +
 +<code>
 +fitmod <- lm(intention ~ attitude + norms + control, data=df)
 +summary(fitmod)
 +</code>
 +
 +<code>
 + 
 +> # 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
 +
 +
 +</code>
 +====== Model 3 ======
 +<code>
 +# 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)
 +</code>
 +<code>
 +> 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
 +
 +</code>
 +
 +<code>
 +a <- (5*(5+1))/2
 +b <- 12
 +a-b 
 +
 </code> </code>
path_analysis.1667996569.txt.gz · Last modified: 2022/11/09 21:22 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki