Это моя первая попытка смоделировать данные - мы хотели бы смоделировать набор данных и решили использовать simstudy, используя следующий код:
def <- defData(varname='median_household_income',formula=mean(
df$median_household_income))
def <- defData(def, varname='share_unemployed_seasonal',formula=mean(
df$share_unemployed_seasonal))
def <- defData(def, varname='share_population_in_metro_areas',
formula=mean(df$share_population_in_metro_areas))
def <- defData(def, varname='share_population_with_high_school_degree',
formula=mean(df$share_population_with_high_school_degree))
def <- defData(def, varname='share_non_citizen',
formula=mean(df$share_non_citizen))
def <- defData(def, varname='share_white_poverty',
formula=mean(df$share_white_poverty))
def <- defData(def, varname='gini_index',formula=mean(df$gini_index))
def <- defData(def, varname='share_non_white',formula=mean(df$share_non_white))
def <- defData(def, varname='share_voters_voted_trump',
formula=mean(df$share_voters_voted_trump))
#outcome
def <- defData(def, varname='avg_hatecrimes_per_100k_fbi',formula=
".0001*median_household_income + 44*share_unemployed_seasonal +
-2.8*share_population_in_metro_areas +
24*share_population_with_high_school_degree + 22*share_non_citizen +
3.2*share_white_poverty + 55*gini_index + -4*share_non_white +
-2.6*share_voters_voted_trump")
#generate simulated data
df_sim <- genData(10000,def)
Вывод выглядит так:
head(df_sim)
id median_household_income share_unemployed_seasonal share_population_in_metro_areas
1: 1 55223.61 0.04956863 0.7501961
2: 2 55223.61 0.04956863 0.7501961
3: 3 55223.61 0.04956863 0.7501961
4: 4 55223.61 0.04956863 0.7501961
5: 5 55223.61 0.04956863 0.7501961
6: 6 55223.61 0.04956863 0.7501961
Почему все сгенерированные значения идентичны?Насколько я понимаю, переменные генерируются в соответствии с нормальным распределением по умолчанию.Любая помощь с этим приветствуется!