murphymv / semEff

Automatic Calculation of Effects for Piecewise Structural Equation Models
https://murphymv.github.io/semEff/
GNU General Public License v3.0
11 stars 0 forks source link

In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated. #39

Closed Canderson156 closed 2 years ago

Canderson156 commented 2 years ago

Hi there. I'm trying to follow along with the instructions on the R vignette and am having absolutely no luck pinpointing why I can't get this to work.

I've created a path model in piecewiseSEM as follows:

test_model <- psem(glm(presence ~ Annual_mean_temp + Snowmelt_DOY + LC_tussock_gram + Substrate_Circumneutral, REPH2, family = binomial), glm(LC_tussock_gram ~ Annual_mean_temp + Substrate_Acidic + Substrate_Circumneutral + Snowmelt_DOY, REPH2, family = binomial), lm(Snowmelt_DOY ~ Annual_mean_temp + Substrate_Acidic + Substrate_Circumneutral , REPH2))

When I try to use semEff functions, I experience the following errors:

test_SEM_boot <- bootEff(test_model, R = 100, seed = 13, parallel = "no")

Warning messages: 1: In (function (m, w) ... : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated.

test_SEM_eff <- semEff(test_SEM_boot)

Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic

I've tried the quite a few things to try to narrow down what this issue might be. I tried making a simpler model with my data only using the variables that would require lm instead of glm. I tried specifying the model exactly as in the vignette, which uses list() instead of psem(). I wondered if something about the structure of my model was problematic so I tried using the exact same path model as in the vignette, but with my data instead of the keeley data.

All of these return Warning messages: 1: In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated. ....

This makes me think my data must be the issue, but I can't see why. Each individual model, and the piecewise SEM model I created seem to be fine - no convergence issues, no errors or warnings, the outputs seem to make sense.

Any thoughts on what I could do to address this issue?

Canderson156 commented 2 years ago

A few updates. My impression is that this seems like a bug, because this code results in warnings and NAs:

keeley.sem2 <- list( lm(Snowmelt_DOY ~ Annual_mean_temp, REPH2), lm(Annual_mean_temp ~ Elevation, REPH2))

keeley.sem.boot2 <- bootEff(keeley.sem2, R = 100, seed = 100, parallel = "no")

Warning messages: 1: In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated. 2: In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated.

The exact same code with a few variables removed from the original data frame appears to produce reasonable looking results. This doesn't make any sense to me, because the linear models aren't even using any of the other data.

REPH3 <- REPH2 %>% select(Snowmelt_DOY, Annual_mean_temp, Elevation)

keeley.sem2 <- list( lm(Snowmelt_DOY ~ Annual_mean_temp, REPH3), lm(Annual_mean_temp ~ Elevation, REPH3))

keeley.sem.boot2 <- bootEff(keeley.sem2, R = 100, seed = 100, parallel = "no")

[[1]]

ORDINARY NONPARAMETRIC BOOTSTRAP

Call: boot::boot(data = x, statistic = s, R = R, parallel = parallel, ncpus = nc, cl = cl)

Bootstrap Statistics : original bias std. error t1 -0.04251895 -0.000816572587 0.006511555 t2 0.05695693 -0.000214670110 0.006564326 t3 0.08361791 0.000006082934 0.005748692 t4 -0.01990412 -0.000271853073 0.006982911 t5* 0.01916960 0.000315435317 0.008548282

[[2]]

ORDINARY NONPARAMETRIC BOOTSTRAP

Call: boot::boot(data = x, statistic = s, R = R, parallel = parallel, ncpus = nc, cl = cl)

Bootstrap Statistics : original bias std. error t1 -0.1114599598 0.001097507298 0.01086540019 t2 -0.0119725055 -0.000140281452 0.00545714387 t3 0.0002585217 -0.000002143330 0.00001458834 t4 0.0002762835 -0.000002223577 0.00001731620 t5* -0.0130210609 -0.000432295403 0.00647399431

[[3]]

ORDINARY NONPARAMETRIC BOOTSTRAP

Call: boot::boot(data = x, statistic = s, R = R, parallel = parallel, ncpus = nc, cl = cl)

Bootstrap Statistics : original bias std. error t1 0.000000000000003006318 -0.000000000000009368466 0.00000000000002112928 t2 -0.689835739377412604512 0.001497604469310909181 0.01568250723436917515 t3 0.047526491468627279913 0.000762978156561622267 0.01657712295320109414 t4 0.090585418846109655444 0.000152002740594708863 0.01679705475165162512

HOWEVER

Something still seems fishy. Even though as far as I know the bootEff results seem reasonable, they do not seem compatible with the semEff function.

keeley.sem.eff <- semEff(keeley.sem.boot) Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic

Canderson156 commented 2 years ago

Here's a reproducible example of that last error message:

data(keeley, package = "piecewiseSEM")

keeley.psem <- psem( lm(age ~ distance, data = keeley), lm(hetero ~ distance, data = keeley), lm(abiotic ~ distance, data = keeley), lm(firesev ~ age, data = keeley), lm(cover ~ firesev, data = keeley), lm(rich ~ distance + hetero + abiotic + cover, data = keeley) )

keeley.psem.boot <- bootEff(keeley.psem, R = 100, seed = 13, parallel = "no") x <- semEff(keeley.psem.boot) Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic

murphymv commented 2 years ago

Hi Christine,

Thanks for your messages and sorry for delay. Have reproduced that last error at my end aswell so will have a look at that.

As for the other issue with bootstrapping returning NAs - at least one other person has had an issue with that that was also apparently fixed by removing some non-specified variables from dataset. It absolutely shouldn't matter how many variables there are or whether they are specified in models so that seems to be a bug of some kind, something to do with the handling of the dataset during resampling perhaps. Will investigate. In the meantime can you rerun the bootstrapping by specifying catch.err = FALSE? This should force the function to stop when a model fitting or other error occurs, and perhaps output the particular error that is occuring.

Thanks, Mark

murphymv commented 2 years ago

Hi,

The second error you were getting is indeed a bug, as bootEff() should have been setting model names to the response variable names if the model list was unnamed. The renaming was happening OK where the names were NULL but not for a character vector of zero-length names (which is what the psem() object produced).

I'll push a fix to CRAN as soon as I can, but in the meantime you can either download the dev version from here or just name each model in the list, e.g.:

keeley.psem <- psem(
  age = lm(age ~ distance, data = keeley),
  hetero = lm(hetero ~ distance, data = keeley),
  ...
)

Names should match the response variable names, to allow these to be referenced properly in the formulas of other models where they may be predictors (i.e. mediators).

For the bootstrapping stuff, what were the variables that you removed from the dataset in order to get it to work properly? Were these just anything that wasn't specified in models, so that the dataset only included specified variables and nothing else? Was there anything special about the removed variables, e.g. lots of NAs or anything like that? Also let me know what errors get produced when you run bootEff(..., catch.err = FALSE).

Cheers, Mark

Canderson156 commented 2 years ago

Hi Mark,

Thanks for looking into all of this.

Here's what I got when I tried catch.err = FALSE

keeley.sem2 <- list(

  • lm(Snowmelt_DOY ~ Annual_mean_temp, REPH2),
  • lm(Annual_mean_temp ~ Elevation, REPH2))

keeley.sem.boot2 <- bootEff(keeley.sem2, R = 100, seed = 100, parallel = "no", catch.err = FALSE)

Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

Here is the structure of the REPH2 dataframe. There are no NAs in the dataset (REPH2 <- REPH[complete.cases(REPH),])

'data.frame': 1749 obs. of 37 variables: $ X : int 3 4 11 12 13 14 21 22 36 39 ... $ Plot : chr "AFI-0002" "AFI-0002" "AFI-0025" "AFI-0025" ... $ Year : int 1997 2019 1997 2019 2019 1997 2019 2019 2001 2001 ... $ Region_Name : chr "Eastern Foxe Basin" "Eastern Foxe Basin" "Eastern Foxe Basin" "Eastern Foxe Basin" ... $ Region_Code : int 3 3 3 3 3 3 3 3 1 1 ... $ Sub_Region_Name : chr "Foxe Basin" "Foxe Basin" "Foxe Basin" "Foxe Basin" ... $ Sub_Region_Code : num 3.1 3.1 3.1 3.1 3.1 3.1 3.1 3.1 10.1 10.1 ... $ Plot_Area_km2 : num 0.16 0.16 0.16 0.16 0.16 ... $ Species : chr "REPH" "REPH" "REPH" "REPH" ... $ max_birds : int 8 0 0 0 0 1 0 0 0 0 ... $ presence : logi TRUE FALSE FALSE FALSE FALSE TRUE ... $ Annual_mean_temp : num -10.9 -10.9 -11.2 -11.2 -11.2 ... $ Mean_diunrnal_range : num 6.25 6.25 6.39 6.39 6.39 ... $ Temp_seasonality : num 1298 1298 1345 1345 1345 ... $ Annual_precip : num 229 229 233 233 233 ... $ Precip_seasonality : num 64.7 64.7 64.5 64.5 64.5 ... $ LC_tussock_gram : num 0.00516 0.00516 0.10946 0.10946 0.06794 ... $ LC_wet_sedge : num 0.00751 0.00751 0.03196 0.03196 0.61474 ... $ LC_non_tussock_gram : num 0.0128 0.0128 0.0754 0.0754 0.1998 ... $ LC_dry_gram_dwarf_shrub: num 0 0 0.1003 0.1003 0.0283 ... $ LC_low_shrub : num 0 0 0.3897 0.3897 0.0322 ... $ LC_high_shrub : num 0.0146 0.0146 0.0317 0.0317 0.0281 ... $ LC_dwarf_shrub : num 0.01581 0.01581 0.05647 0.05647 0.00786 ... $ LC_sparse_veg_bedrock : num 0.00536 0.00536 0.05142 0.05142 0.0151 ... $ LC_sparse_veg_till : num 0 0 0.0434 0.0434 0.0059 ... $ LC_cryptogram_crust : num 0 0 0.0158 0.0158 0 ... $ LC_wetlands : num 0.9388 0.9388 0.0646 0.0646 0 ... $ LC_barren : num 0 0 0.00804 0.00804 0 ... $ Substrate : chr "Acidic" "Acidic" "Acidic" "Acidic" ... $ Snowmelt_DOY : num 179 179 168 168 170 ... $ Elevation : num 4.15 4.15 4.12 4.12 4.12 ... $ Stdev_elevation : num 1.888 1.888 0.014 0.014 0.014 ... $ Dist2Coast_km : num 0.396 0.396 10.176 10.176 8.912 ... $ Substrate_Acidic : int 1 1 1 1 1 1 1 1 1 1 ... $ Substrate_Carbonate : int 0 0 0 0 0 0 0 0 0 0 ... $ Substrate_Circumneutral: int 0 0 0 0 0 0 0 0 0 0 ... $ Substrate_NA : int 0 0 0 0 0 0 0 0 0 0 ...

Canderson156 commented 2 years ago

In case this is helpful at all:

I tried to set up my model addressing both of the issues we've discussed, and still appear to be getting an error. I set up the dataframe so that it only contains the variables I'm using in the model, and I named the model lists as you described.

REPH3 <- REPH2 %>% select(presence, Annual_mean_temp, Snowmelt_DOY, LC_high_shrub, Substrate)

test_model <- psem( presence = glm(presence ~ Annual_mean_temp + Snowmelt_DOY + LC_high_shrub + Substrate, REPH3, family = binomial), LC_high_shrub = glm( LC_high_shrub ~ Annual_mean_temp + Substrate, REPH3, family = binomial), Snowmelt_DOY = lm(Snowmelt_DOY ~ Annual_mean_temp + Substrate , REPH3))

summary(test_model, direction = c("Snowmelt_DOY -> LC_high_shrub" ))

test_SEM_boot <- bootEff(test_model, R = 100, seed = 13, parallel = "no")

test_SEM_boot $presence

ORDINARY NONPARAMETRIC BOOTSTRAP

Call: boot::boot(data = x, statistic = s, R = R, parallel = parallel, ncpus = nc, cl = cl)

Bootstrap Statistics : original bias std. error t1 -0.0439114901 -0.0236857552 0.027242152 t2 0.0566685018 -0.0001965591 0.006640300 t3 0.0842502092 0.0001336703 0.005986237 t4 -0.0001648101 -0.0010120774 0.006879053 t5 -0.0284391556 -0.1010870887 0.117423835 t6 0.0141985739 0.0001392685 0.008691380

$LC_high_shrub

ORDINARY NONPARAMETRIC BOOTSTRAP

Call: boot::boot(data = x, statistic = s, R = R, parallel = parallel, ncpus = nc, cl = cl)

Bootstrap Statistics : original bias std. error t1 -0.0006777686 -0.0003890097 0.0007079732 t2 0.0060352176 -0.0007086510 0.0047506724 t3 -0.0155964635 -0.0020641530 0.0104405279 t4 0.0051197639 0.0007142286 0.0054819725

$Snowmelt_DOY

ORDINARY NONPARAMETRIC BOOTSTRAP

Call: boot::boot(data = x, statistic = s, R = R, parallel = parallel, ncpus = nc, cl = cl)

Bootstrap Statistics : original bias std. error t1 0.000000000000003006318 -0.000000000000009247794 0.00000000000002056832 t2 -0.689835739377412715534 0.001497604469311020203 0.01568250723436917168 t3 -0.050814125661849174342 -0.000794796233755730441 0.01773054215481430912 t4 0.083395225596891039976 -0.001040677511153498269 0.01855180383159249144

test_SEM_eff <- semEff(test_SEM_boot)

Error in bca.ci(boot.out, conf, index[1L], L = L, t = t.o, t0 = t0.o, : estimated adjustment 'a' is NA

murphymv commented 2 years ago

Christine,

I think I've found (and squashed) the bug that was giving you this error to do with contrasts:

Error in contrasts<-(tmp, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

Basically there's a (mostly internal) function called getX() which was likely trying to coerce all the character variables in your REPH2 dataset to factors so that it can generate dummy variables (for its own nefarious purposes...). Mostly this is OK, but it was also probably (incorrectly) trying to coerce character variables which have only one value, leading to the error with factor contrasts (i.e. they can't be applied in that case). Did you have any such variables in there? Anyway I've pushed a fix for that to the dev version on here, so you could try again using that version (devtools::install_github("murphymv/semEff@dev")) and let me know? I'll release a patch version to CRAN soon incorporating these latest fixes.

The second error you were getting is likely because there are not enough bootstrap samples to calculate the adjustment factor for the BCa confidence intervals. I'd suggest increasing the R to 1000 or so, or alternatively you could change the ci.type argument of semEff() to something else (see the type argument of boot::boot.ci() for options).

Thanks for your help with this.

Mark

Canderson156 commented 2 years ago

Super, thanks so much. I do in fact have a variable with only one value, so what you described makes sense. I'll try it out again with the development version this week.

Canderson156 commented 2 years ago

I'm still having the same issues. I have ‘semEff’ version 0.6.0.9000.

I have a psem model that seems fine, no errors or warnings.

test_model <- psem(lm(Snowmelt_DOY ~ Annual_mean_temp + Annual_precip + Elevation, species_train2$WRSA), lm(Annual_precip ~ Annual_mean_temp + Dist2Coast_km + Elevation, species_train2$WRSA))

summary(test_model)

Structural Equation Model of test_model

Call: Snowmelt_DOY ~ Annual_mean_temp + Annual_precip + Elevation Annual_precip ~ Annual_mean_temp + Dist2Coast_km + Elevation

AIC      BIC

20.738 68.377


Tests of directed separation:

                  Independ.Claim Test.Type  DF Crit.Value P.Value 

Snowmelt_DOY ~ Dist2Coast_km + ... coef 861 -0.3969 0.6915

Global goodness-of-fit:

Fisher's C = 0.738 with P-value = 0.692 and on 2 degrees of freedom


Coefficients:

   Response        Predictor Estimate Std.Error  DF Crit.Value P.Value Std.Estimate    

Snowmelt_DOY Annual_mean_temp -3.2629 0.1447 862 -22.5550 0.0000 -1.0250 Snowmelt_DOY Annual_precip 0.0485 0.0050 862 9.6178 0.0000 0.4272 Snowmelt_DOY Elevation -0.0169 0.0019 862 -9.0445 0.0000 -0.2349 Annual_precip Annual_mean_temp 23.5874 0.5632 862 41.8788 0.0000 0.8410 Annual_precip Dist2Coast_km 0.0436 0.0256 862 1.7035 0.0888 0.0378
Annual_precip Elevation 0.0723 0.0143 862 5.0455 0.0000 0.1139 ***

Signif. codes: 0 '' 0.001 '' 0.01 '' 0.05


Individual R-squared:

   Response method R.squared

Snowmelt_DOY none 0.47 Annual_precip none 0.69

But I get the same error message as before when I try to run bootEff:

test_boot <- bootEff(test_model, R = 100, seed = 100, parallel = "no") Warning messages: 1: In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated. 2: In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated.

test_boot <- bootEff(test_model, R = 100, seed = 100, parallel = "no", catch.err = FALSE) Error in FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...) : non-numeric argument to binary operator

I also have a more complex full model that I want to test. bootEff works, but has warnings. semEff throws an error.

WRSA_boot <- bootEff(path_WRSA, R = 1000, seed = 100, parallel = "no")

1: glm.fit: fitted probabilities numerically 0 or 1 occurred ....

60: In (function (m, w) ... : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated. ....

1284: In (function (m, w) ... : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated.

WRSA_semEff <- semEff(WRSA_boot)

Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic

Any thoughts? I'm a bit confused why it says the GLM had fitted probabilities numerically 0 or 1 when this isn't an issue when I look at the summary of the psem object

Canderson156 commented 2 years ago

I just learned how to do this. Maybe this will be helpful

test_data <- structure(list(Plot = c("AFI-0103A", "AFI-0103D", "ALE-7150", "ARV-0101A", "ARV-0101D", "ARV-0103A"), Year = c(2019, 2019, 2007, 2015, 2015, 2015), Region_Name = c("Eastern Foxe Basin", "Eastern Foxe Basin", "North Archipelago", "Southwest Hudson Barrens", "Southwest Hudson Barrens", "Southwest Hudson Barrens"), Region_Code = c(3, 3, 1, 6, 6, 6), Sub_Region_Name = c("Foxe Basin", "Foxe Basin", "Queen Elizabeth Islands", "SW Hudson Barrens", "SW Hudson Barrens", "SW Hudson Barrens"), Sub_Region_Code = c(3.1, 3.1, 10.1, 6.1, 6.1, 6.1), Plot_Area_km2 = c(0.121, 0.121, 0.12, 0.124, 0.124, 0.124), Species = c("WRSA", "WRSA", "WRSA", "WRSA", "WRSA", "WRSA" ), max_birds = c(1, 0, 0, 0, 0, 0), presence = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE), Annual_mean_temp = c(-11.2382965087891, -11.2382965087891, -16.0021305084229, -10.183741569519, -10.183741569519, -10.4481935501099), Mean_diurnal_range = c(6.38814067840576, 6.38814067840576, 4.57023572921753, 8.11931610107422, 8.11931610107422, 7.8389253616333), Temp_seasonality = c(1345.49377441406, 1345.49377441406, 1227.11389160156, 1593.83459472656, 1593.83459472656, 1591.27319335938 ), Annual_precip = c(232.506439208984, 232.506439208984, 153.791290283203, 299.914886474609, 299.914886474609, 295.033599853516), Precip_seasonality = c(64.498893737793, 64.498893737793, 57.8097496032715, 61.014461517334, 61.014461517334, 60.6461524963379), Substrate = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Acidic", "Carbonate", "Circumneutral"), class = "factor"), Snowmelt_DOY = c(179.14338684082, 179.866737365723, 176.291404724121, 160.736175537109, 160.084976196289, 160.636756896973), Elevation = c(4.11714363098145, 4.11714363098145, 307.674438476562, 120.849990844727, 120.849990844727, 93.8265533447266), Stdev_elevation = c(0, 0, 92.1246185302734, 22.1414184570312, 22.1414184570312, 20.3355484008789), Dist2Coast_km = c(1.82123780250549, 2.12087607383728, 2.71990633010864, 139.898818969727, 138.959274291992, 123.350738525391), Upland = c(0, 0, 75, 80, 0, 40), Lowland = c(95, 100, 20, 20, 90, 10), Habitat_Quality_Code = c(2L, 2L, 1L, 1L, 1L, 1L), barren = c(0.0133759938277635, 0.00813989220237405, 0.193087667461799, 0.0109056342361559, 0.00770425770159539, 0.00899760531706845), cryptogram_crust = c(0.0197554779592308, 0.0199272064373947, 0.0277169272279651, 0.00993024500453353, 0.0100955644148364, 0.00884037708394355), dry_gram_dwarf_shrub = c(0.0146969386247787, 0.0154429200343285, 0.00344263330569551, 0.0918878779897474, 0.0932778726993184, 0.13288078276407), dwarf_shrub = c(0.00810201420618663, 0.00852314192038731, 0.00503140655057639, 0.0454177094044828, 0.0459867161292567, 0.0290401400336045), high_shrub = c(0.0150823431825081, 0.00114643935658968, 0.00687863613812089, 0.0249699323008167, 0.0232118869176526, 0.0181145951221045), low_shrub = c(0.0121914544688722, 0.0127486908495301, 0.00394232616366127, 0.0739014129202792, 0.0741302760690303, 0.16569728781003), nontussock_gram = c(0.04360348763893, 0.0456603063089347, 0.00370339132420137, 0.118326227118641, 0.121128823279036, 0.128891843702839), sparse_veg_bedrock = c(0.00577714640355352, 0.00602250398585902, 0.00588294204840536, 0.0119413324922114, 0.0123595161694443, 0.0112913980635867), sparse_veg_till = c(0.0813865217900137, 0, 0.0121342706807564, 0.00318455376877787, 0.00875752286189448, 0.0105333487603569), tussock_gram = c(0.0542979394480203, 0.0360412168672579, 0, 0.407148292212359, 0.374790077320818, 0.165182227055799), wet_sedge = c(0.514129383835857, 0.686973026042063, 0.0246525947894635, 0.137423170085191, 0.153740300674496, 0.158068781648382), wetlands = c(0.00739352674234003, 0.00734373738838291, 0.392992296820684, 0.00827860072782241, 0.00788310279101328, 0.00791700460520419)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

test_model <- psem(lm(Snowmelt_DOY ~ Annual_mean_temp + Annual_precip + Elevation, test_data), lm(Annual_precip ~ Annual_mean_temp + Dist2Coast_km + Elevation, test_data))

WRSA_boot <- bootEff(test_model, R = 100, seed = 100, parallel = "no") WRSA_semEff <- semEff(WRSA_boot)

murphymv commented 2 years ago

Hi,

I ran your code and it seems like the error you were getting is an introduced bug from the last bugfix (my bad again), so it should be sorted now in the dev version if you want to try that?

The GLM fitted probabilities warning is likely because you are doing nonparametric bootstrapping which resamples the dataset R times, and which increases the chances that one or more of those resampled datasets is structured so that it causes the GLM some fitting/convergence issues (e.g. outliers, a binary response dominated by zeros or ones, etc.). Note that often there may only be a small number of such fitting warnings/errors in a large bootstrap run, which may not be a big deal and could be safely ignored. To try and minimise such issues however, you could try changing the seed to something else, which will resample the data differently. For mixed models, you could also try bootEff(..., type = "parametric").

Thanks, Mark

ghost commented 2 years ago

Hi mark,

My apologies for not responding, I've been bed ridden with a stomach flu for a few days. I'll have a look through your responses once I'm back at my desk.

Thank you so much, Leanne

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Mark Murphy @.> Sent: Monday, April 18, 2022 11:51:23 PM To: murphymv/semEff @.> Cc: Subscribed @.***> Subject: Re: [murphymv/semEff] In (function (m, w) : 101 model fit(s) or parameter estimation(s) failed. NAs reported/generated. (Issue #39)

Hi,

I ran your code and it seems like the error you were getting is an introduced bug from the last bugfix (my bad again), so it should be sorted now in the dev version if you want to try that?

The GLM fitted probabilities warning is likely because you are doing nonparametric bootstrapping which resamples the dataset R times, and which increases the chances that one or more of those resampled datasets is structured so that it causes the GLM some fitting/convergence issues (e.g. outliers, a binary response dominated by zeros or ones, etc.). Note that often there may only be a small number of such fitting warnings/errors in a large bootstrap run, which may not be a big deal and could be safely ignored. To try and minimise such issues however, you could try changing the seed to something else, which will resample the data differently. For mixed models, you could also try bootEff(..., type = "parametric").

Thanks, Mark

— Reply to this email directly, view it on GitHubhttps://github.com/murphymv/semEff/issues/39#issuecomment-1101424443, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYJ3NPMZSDXVQOQBDW4UK33VFVSFXANCNFSM5ROVU35Q. You are receiving this because you are subscribed to this thread.Message ID: @.***>