library(foreign)
library(tidyLPA)
## Warning: package 'tidyLPA' was built under R version 3.4.4
## tidyLPA provides the functionality to carry out Latent Profile Analysis. Note that tidyLPA is still at the beta stage!
## Please report any bugs at https://github.com/jrosen48/tidyLPA or send an email to jrosen@msu.edu.
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.4
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
data <- read.spss("data.sav", to.data.frame = T)
## Warning in read.spss("data.sav", to.data.frame = T): data.sav: Very long
## string record(s) found (record type 7, subtype 14), each will be imported
## in consecutive separate variables
#data <- data %>% filter(., Gender == "גבר") #
#"גבר"
#"אישה"
data <- select(data, serial, Abuse, Gender, RTA_factor_1, RTA_factor_2,
RTA_factor_3, RTA_factor_4, SexVictimization_no1,
Physical_victimization, SexVictimization_agg_no1,
Physical_Aggression)
data <- filter(data, Abuse == "reported an abuse")
## Warning: package 'bindrcpp' was built under R version 3.4.4
data <- select(data, RTA_factor_1, RTA_factor_2, RTA_factor_3, RTA_factor_4)
compare_solutions(data, RTA_factor_1, RTA_factor_2, RTA_factor_3, RTA_factor_4)
It appears as though model 2 with 2 profiles fits best (as indicated by low BIC). Model 3 with 3 profiles has the lowest BIC but I’m suspicious of it due to large variance.
model <- estimate_profiles(data,
RTA_factor_1, RTA_factor_2, RTA_factor_3, RTA_factor_4,
model = 2,
n_profiles = 2,
return_orig_df = TRUE)
## Fit varying means, equal variances and covariances (Model 2) model with 2 profiles.
## LogLik is 5493.057
## BIC is 11094.924
## Entropy is 0.925
model2 <- estimate_profiles(data,
RTA_factor_1, RTA_factor_2, RTA_factor_3, RTA_factor_4,
model = 2,
n_profiles = 2,
return_orig_df = TRUE)
## Fit varying means, equal variances and covariances (Model 2) model with 2 profiles.
## LogLik is 5493.057
## BIC is 11094.924
## Entropy is 0.925
#write.csv(model6, "dataWithProfiles_maleIncluded.csv", row.names = F)
Entropy is above .8 suggesting distinct profiles.
plot_profiles(model2) #to_center = TRUE, to_scale = TRUE
plot_profiles(model2, to_center = T) #to_center = TRUE, to_scale = TRUE
plot_profiles(model2, to_center = T, to_scale = T) #to_center = TRUE, to_scale = TRUE