R-experts,

The R script here below.

How to solve my problem ? 

Best,


##############################
# Load packages
 
install.packages("remotes")
remotes::install_github("bd2kccd/r-causal")
 
# Install 'gssr' from 'ropensci' universe
install.packages('gssr', repos =
 c('https://kjhealy.r-universe.dev', 'https://cloud.r-project.org'))
 
# Also recommended: install 'gssrdoc' as well
install.packages('gssrdoc', repos =
 c('https://kjhealy.r-universe.dev', 'https://cloud.r-project.org'))
 
library(dplyr)
library(gssr)

set.seed(123)


# Load dataset

data("gss_panel06_long")
 

# Filter one wave, remove variables with high NA, and keep usable types

base_df <- gss_panel06_long %>%

  filter(year == 2006) %>%

  select_if(~ is.numeric(.) || is.factor(.)) %>%

  select_if(~ sum(is.na(.)) < 0.1 * n()) %>%

  na.omit()

 
# Sample sizes to test

sample_sizes <- c(30, 50, 100, 300, 500)

 
# Set plotting layout

par(mfrow = c(2, 3))  # 2 rows, 3 columns

 
# Loop through sample sizes

for (n in sample_sizes) {

  df_sample <- sample_n(base_df, n)

  result <- gfci(data = df_sample, test = "kci", score = "sem-bic")

  plot(result, main = paste("n =", n))

}
#################################
 

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to