Skip to content

Commit

Permalink
removed lines and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
brandmaier committed Dec 21, 2024
1 parent 4a7baea commit 14a738f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 0 additions & 4 deletions tests/lavaan.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ require("lavaan")

data(lgcm)

lgcm$agegroup <- as.ordered(lgcm$agegroup)
lgcm$training <- as.factor(lgcm$training)
lgcm$noise <- as.factor(lgcm$noise)

# LOAD IN LAVAAN MODEL.
# A SIMPLE LINEAR GROWTH MODEL WITH 5 TIME POINTS FROM SIMULATED DATA

Expand Down
19 changes: 12 additions & 7 deletions tests/testthat/prediction.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
skip_on_cran()

N<-100
library(semtree)
# generate data with two observed variables x,y
# and two predictors
#
N<-1000
x<-rnorm(N)
y<-rnorm(N)
pred1 <- ordered( sample(c(0,1,2),N,replace=TRUE) )
pred2 <- sample(0:10, N, replace=TRUE)

y2 <- ifelse(pred2>5,0.2*y+0.8*x,x)

# define a fully saturated model
model <- "x~~y; x~~x;y~~y"

df <- data.frame(x,y=y2,pred1,pred2)
sim_data <- data.frame(x,y=y2,pred1,pred2)

fitted_model <- lavaan(model,df)
tree <- semtree(fitted_model, df)
fitted_model <- lavaan::lavaan(model,sim_data)
tree <- semtree(fitted_model, sim_data, control = semtree_control(method="score",verbose=TRUE))
plot(tree)

forest <- semforest(fitted_model, df)
forest <- semforest(fitted_model, sim_data)

pars_pred <- predict(forest, df, "pars")
pars_pred <- predict(forest, sim_data, "pars")


#pars_pred <- predict(strip(forest), df, "pars")
#pars_pred <- predict(strip(forest), sim_data, "pars")

0 comments on commit 14a738f

Please sign in to comment.