Nonlinear model convergence - r
I have a time series data set and each time series has datapoint of 30-year from different/same species. I am developing a forecasting model using the first 23 years of data from each time series data point and I am using the rest 7 years as test set to know the predictive ability of model but the nonlinear model (Model 6 and Model 7) don't give succinct result?
Data:
DD <- structure(list(Plot = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("A",
"B", "C", "D"), class = "factor"), Species = structure(c(2L,
2L, 2L,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, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L,
60L, 61L, 62L, 63L, 64L, 65L, 66L, 37L, 38L, 39L, 40L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 37L, 38L,
39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L,
52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L,
65L, 66L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L,
61L, 62L, 63L, 64L, 65L, 66L, 37L, 38L, 39L, 40L, 41L, 42L, 43L,
44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L,
57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 37L, 38L, 39L,
40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L,
53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L,
66L), Count = c(81L, 45L, 96L, 44L, 24L, 8L, 28L, 32L, 39L, 29L,
40L, 17L, 4L, 12L, 18L, 11L, 63L, 98L, 78L, 76L, 67L, 36L, 56L,
43L, 81L, 8L, 14L, 20L, 25L, 19L, 135L, 91L, 171L, 88L, 59L,
1L, 1L, 1L, 2L, 1L, 11L, 9L, 34L, 15L, 32L, 21L, 33L, 43L, 39L,
20L, 6L, 3L, 9L, 9L, 28L, 16L, 15L, 2L, 1L, 1L, 34L, 16L, 19L,
35L, 32L, 7L, 2L, 30L, 29L, 25L, 28L, 11L, 31L, 31L, 28L, 27L,
34L, 110L, 87L, 103L, 72L, 19L, 46L, 43L, 107L, 32L, 26L, 31L,
12L, 29L, 23L, 40L, 50L, 23L, 34L, 11L, 9L, 4L, 24L, 55L, 14L,
16L, 51L, 43L, 2L, 13L, 8L, 96L, 52L, 118L, 32L, 1L, 8L, 17L,
34L, 29L, 38L, 15L, 4L, 38L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 3L,
4L, 6L, 4L, 4L, 10L, 6L, 7L, 9L, 15L, 30L, 25L, 36L, 13L, 17L,
43L, 36L, 60L, 50L, 26L, 13L, 13L, 27L, 18L, 56L, 96L, 16L, 54L,
2L, 2L, 9L, 5L, 5L, 6L, 2L, 6L, 2L, 3L, 4L, 3L, 136L, 71L, 116L,
28L, 23L, 76L, 64L, 98L, 58L, 26L, 13L, 13L, 13L, 18L, 19L, 24L,
18L, 17L, 3L, 23L, 19L, 9L, 11L, 13L, 20L, 29L, 29L, 17L, 20L,
26L, 71L, 63L, 53L, 54L, 20L, 22L, 18L, 93L, 50L, 18L, 12L, 12L,
31L), LogCount = c(1.908385019, 1.653212514, 1.982271233, 1.643462676,
1.380211242, 0.903089987, 1.447158031, 1.505109978, 1.591064607,
1.462397998, 1.602059991, 1.230448921, 0.602059991, 1.079181206,
1.255272505, 1.041392685, 1.799340549, 1.991226076, 1.892094603,
1.880813592, 1.826074803, 1.556302501, 1.748188027, 1.633468456,
1.908485019, 0.903089987, 1.146128035, 1.301029996, 1.397940009,
1.278753601, 2.130333768, 1.95904139, 2.2329961, 1.94448267,
1.770852012, 0, 0, 0, 0.30102999, 0, 1.0411392685, 0.954242509,
1.531478917, 1.176031259, 1.505149978, 1.322219295, 1.51851394,
1.6334684456, 1.591064607, 1.301029996, 0.77815125, 0.477121255,
0.954242509, 0.954242509, 1.447158031, 1.204119983, 1.176091259,
0.301029996, 0, 0, 1.531478917, 1.204119983, 1.278753501, 1.544068044,
1.505149978, 0.084509804, 0.301029996, 1.477121255, 1.462397998,
1.397940009, 1.447158031, 1.041392685, 1.491361694, 1.491361694,
1.447158031, 1.431363754, 1.531478917, 2.041392685, 1.939519253,
2.012837225, 1.857332495, 1.278753601, 1.662757382, 1.633468456,
2.029383778, 1.505149978, 1.414973348, 1.491361594, 1.079181245,
1.462397998, 1.361727835, 1.602059991, 1.698970004, 1.361727836,
1.531478917, 1.041392685, 0.954242509, 0.602059991, 1.380211242,
1.740362689, 1.146128036, 1.204119983, 1.707570176, 1.633468456,
0.301029996, 1.113943352, 0.903089987, 1.982271233, 1.716003344,
2.071882007, 1.50514997, 0, 0.903089987, 1.230448921, 1.53147891,
1.2397998, 1.57978359, 1.176091259, 0.602059991, 1.57978359,
0.301029996, 0, 0, 0, 0, 0, 0.477121255, 0.477121255, 0.602059991,
0.77815125, 0.602059991, 0.602059991, 1, 0.77815125, 0.84509804,
0.95424509, 1.176091259, 1.477121255, 1.39790009, 1.555302501,
1.113943352, 1.230448921, 1.633468456, 1.555302501, 1.77815125,
1.698970004, 1.414973348, 1.113943352, 1.113943352, 1.431353754,
1.255272505, 1.748188027, 1.982271233, 1.204119983, 1.73239376,
1.431363754, 1.361727835, 0.954242509, 0.698970004, 0.698970004,
0.77815125, 0.301029996, 0.77815125, 0.301029996, 0.477121255,
0.602059991, 0.477121255, 2.133538908, 1.851258349, 2.064457989,
1.447158031, 1.361727836, 1.880813592, 1.806179974, 1.991226076,
1.763427994, 1.414973348, 1.113943352, 1.113943352, 1.113943352,
1.255272505, 1.278753601, 1.380211242, 1.255272505, 1.230446921,
0.477121255, 1.361727835, 1.278753601, 0.954242509, 1.0411392685,
1.113943352, 1.301029996, 1.462397998, 1.462397998, 1.230448921,
1.301029995, 1.414973348, 1.851258349, 1.799340549, 1.72427587,
1.73239376, 1.301029996, 1.342422681, 1.255272505, 1.968482949,
1.698970004, 1.255272505, 1.079181246, 1.079181246, 1.491361694
), Diff = c(-0.255272505, 0.329058719, -0.338818557, -0.263241434,
-0.077121255, 0.544068044, 0.057991947, 0.085910629, -0.128666609,
0.139661993, -0.37161107, -0.62838893, 0.477121255, 0.176091259,
-0.21387982, 0.757947864, 0.191885527, -0.099131473, -0.011281011,
-0.054738789, -0.269772302, 0.191885526, -0.114719571, 0.275016563,
-1.005395032, 0.243038049, 0.15490196, 0.096910013, -0.119186408,
NA, -0.171292376, 0.273954718, -0.288513438, -0.17363066, -1.770852012,
0, 0, 0.301029996, -0.301029996, 1.041392685, -0.087150176, 0.577235408,
-0.355387658, 0.329058719, -0.182930683, 0.196294545, 0.110954516,
-0.042403849, -0.290034611, -0.522878746, -0.301029995, 0.477121254,
0, 0.492915522, -0.243038048, -0.028028724, -0.875061263, -0.301029996,
0, 1.531078917, -0.32735893, 0.070633618, 0.265310043, -0.038918066,
-0.660051938, -0.544068044, 1.176091259, -0.014723257, -0.064457989,
0.049218022, -0.405765346, 0.449969009, 0, -0.044203663, -0.015794267,
0.100115153, 0.509913768, -0.101873432, 0.073317972, -0.155504729,
-0.578578895, 0.384054231, -0.029289376, 0.395915322, -0.5202338,
-0.09017663, 0.076388346, -0.412180448, 0.383216752, -0.100670162,
0.240332155, 0.096910013, -0.337242168, 0.169751081, -0.490086232,
-0.087150176, -0.352182518, 0.778151251, 0.360151447, -0.594234653,
0.057991947, 0.503450193, -0.07410172, -1.33243846, 0.812913356,
-0.210853365, 1.079181246, -0.266267889, 0.355878663, -0.566732029,
-1.505149978, 0.903089987, 0.327358934, 0.301029996, -0.069080919,
0.117385599, -0.403692338, -0.574031268, 0.977723606, -1.278753601,
-0.301029996, 0, 0, 0, 0, 0.477121255, 0, 0.124938736, 0.176091259,
-0.176091259, 0, 0.397490009, -0.2218485, 0.06690679, 0.10914469,
0.22184875, 0.301029996, -0.079181206, 0.158362092, -0.442359149,
0.116505569, 0.403019535, -0.077165955, 0.221848749, -0.079181206,
-0.283996656, -0.301029996, 0, 0.317420412, -0.176091259, 0.492915522,
0.23483206, -0.77815125, 0.528273777, -0.301029996, -0.069635928,
-0.407485327, -0.255272505, 0, 0.079181246, -0.477121254, 0.477121254,
-0.477121254, 0.176091259, 0.124938736, -0.124938736, 1.656417653,
-0.282280559, 0.21319964, -0.617299958, -0.085430195, 0.5191085756,
-0.074533518, 0.185045102, -0.227798082, -0.348454546, -0.301029996,
0, 0, 0.141329153, 0.023481096, 0.101457641, -0.124938737, -0.024823584,
-0.753327666, 0.884606581, -0.082974235, -0.324511092, 0.087150176,
0.072550667, 0.187086644, 0.161368002, 0, -0.231949077, 0.070581075,
0.113903352, 0.436285001, -0.00519178, -0.075054679, 0.00811789,
-0.431363764, 0.041392685, -0.087150176, 0.713210444, -0.269512945,
-0.443697499, -0.176091259, 0, 0.412180448, -0.148939013)), class = "data.frame", row.names = c(NA,
-210L))
Code:
for(f in 1:11){
for(b in 1:5){
for (c in 1:5){
#To select test sets 1,2,3,4, and 5 years beyond the training set:
#Calculate the mean of abundance for the training set years.
Model1<-lm(mean~1, data=DD1)
#
Output2:
2 3 0.676209994477288 1.9365051784348e-09 4.44089209850063e-16
3 53 11.9236453578109 2.06371097988267e-09 1.13686837721616e-13
4 31 1.94583877614293 1.11022302462516e-15 1.99840144432528e-15
5 4 8.06660449042397 1.48071350736245e-08 3.19744231092045e-14
6 5 10.5321102149558 9.31706267692789e-10 1.4210854715202e-14
..
First, please see the time series graph of counts for different species and plots below.
library(ggplot2)
ggplot(DD, aes(Year, Count)) +
geom_point() +
geom_line() +
facet_grid(Plot ~ Species) +
scale_y_log10()
It is seen that there is no obvious trend which can be fitted by power or log-power function using nls.
Second, as I understand you are trying to use nls to predict outside the training data set. Usually it is not quite an effective to use least square models because of auto-correlated nature of time-series.
Third, the simplest prediction algorithm is Holt-Winters (see "dirty" implementation below). You can use as well a ton of other algorithms like ARIMA, exponential smoothing state space etc.
x <- ts(DD[DD$Species == "BG" & DD$Plot == "elq1a3", ]$LogCount)
m <- HoltWinters(x, gamma = FALSE)
library(forecast)
f <- forecast(m, 2)
plot(f, main = "elq1a3 at BG")
Fourth, about your algorithm in question, it throws
Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve.
The reason is that in the first step of for-loop (at f = b = c = 1 DD2 data frame contains just one row. And executing
Model6<-nls(Diff~1+Count^T,start=list(T=1),trace=TRUE,algorithm ="plinear",data=DD2)
means that you are trying to fit a curve using only one data point, which is impossible.
However if you change f value in for-loop from 1:11 to 2:11 another error thrown:
Error in nls(Diff ~ 1 + Count^T, start = list(T = 1), trace = TRUE,
algorithm = "plinear", : step factor 0.000488281 reduced below
minFactor 0.000976562.
In this case you cannot use "naive" approach used by plinear algorithm with self-starting inital value and, e.g. nls.control(min.factor = 1e-5). You must feed all initial coefficients explicitely with default Gauss-Newton algorithm. Quite exausting, please try yourself :)
Related
How to create a barplot based on a condition in ggplot2 (R)?
I have the following code: set.seed(123) CIS_data_5 <- data.frame( CIS$P20, CIS$P3 ) CIS$P3 <- factor(CIS$P3, labels = c("Mejor", "(NO LEER) Igual", "Peor", "N.S.", "N.C.")) n <- as.numeric(c(CIS$P20)) P20 <- sample(n, 2787, replace = TRUE, prob = NULL) P20labs <- c("16-29", "30-44", "45-64", ">65", "N.C.") cut_points <- c(16, 30, 45, 65, Inf) i <- findInterval(P20, cut_points) P20_fac <- P20labs[i] P20_fac[is.na(P20)] <- P20labs[length(P20labs)] P20_fac <- factor(P20_fac, levels = P20labs) where P3 has 5 categories, indicating the socioeconomic perception of a sample of Spanish population, and P20_fac has 5 other categories that indicate the age of the respondents. My desired outcome would be to have 5 joint graphs, in which the socioeconomic situation (P3) is reflected according to the age of the respondents (P20_fac). I have been stuck on thinking how I can possibly represent this graphically, and after many an hour spent, I have completely run out of ideas (though I think that it can somehow be done by means of facet_wrap() or facet_grid()). Any help would be much appreciated! Many thanks in advance! EDIT Regarding what is my question, I have already stated that "My desired outcome would be to have 5 (grouped together) graphs, in which the socioeconomic situation (P3) is represented based on the age of the respondents (P20_fac)." If I knew how to answer it, I most surely would not be making this question on this forum. UPDATE The closest that I've got to the desired result is by running the following code: plot(CIS$P3 ~ P20_fac, data = CIS) However, it only gets me the graphical results for the first age interval ("16-29") and in vertical instead of horizontal form. dput(CIS_data_5) > dput(CIS_data_5) structure(list(CIS.P20 = structure(c(48L, 33L, 28L, 36L, 32L, 24L, 27L, 50L, 55L, 34L, 48L, 22L, 37L, 24L, 35L, 35L, 19L, 57L, 32L, 45L, 13L, 23L, 24L, 5L, 8L, 34L, 2L, 52L, 66L, 43L, 54L, 24L, 27L, 40L, 40L, 64L, 29L, 12L, 52L, 7L, 26L, 40L, 59L, 19L, 24L, 44L, 19L, 62L, 26L, 16L, 40L, 31L, 14L, 15L, 29L, 24L, 41L, 33L, 41L, 3L, 39L, 4L, 44L, 39L, 1L, 28L, 40L, 8L, 49L, 59L, 50L, 8L, 8L, 9L, 41L, 35L, 35L, 65L, 40L, 38L, 29L, 24L, 54L, 40L, 21L, 29L, 3L, 27L, 45L, 50L, 27L, 50L, 60L, 50L, 41L, 56L, 57L, 33L, 45L, 31L, 58L, 3L, 16L, 43L, 25L, 40L, 32L, 17L, 58L, 46L, 15L, 40L, 22L, 28L, 11L, 38L, 50L, 22L, 25L, 47L, 17L, 32L, 36L, 49L, 40L, 23L, 17L, 34L, 8L, 37L, 67L, 37L, 52L, 60L, 5L, 55L, 45L, 40L, 36L, 46L, 50L, 13L, 73L, 31L, 33L, 47L, 58L, 37L, 55L, 16L, 38L, 32L, 15L, 45L, 33L, 9L, 47L, 10L, 9L, 33L, 41L, 31L, 31L, 21L, 28L, 26L, 68L, 15L, 63L, 38L, 59L, 30L, 47L, 21L, 36L, 50L, 40L, 30L, 14L, 54L, 16L, 60L, 8L, 44L, 49L, 68L, 33L, 24L, 58L, 27L, 34L, 33L, 47L, 50L, 52L, 15L, 21L, 16L, 47L, 59L, 37L, 34L, 11L, 37L, 50L, 9L, 41L, 51L, 31L, 35L, 26L, 5L, 24L, 51L, 6L, 27L, 52L, 68L, 8L, 39L, 33L, 51L, 41L, 53L, 39L, 60L, 43L, 10L, 51L, 26L, 41L, 51L, 54L, 35L, 33L, 35L, 39L, 28L, 48L, 5L, 31L, 50L, 8L, 45L, 50L, 41L, 53L, 54L, 32L, 43L, 65L, 22L, 32L, 24L, 35L, 40L, 34L, 41L, 19L, 48L, 46L, 35L, 24L, 12L, 35L, 19L, 8L, 30L, 58L, 55L, 16L, 37L, 17L, 1L, 35L, 40L, 50L, 50L, 53L, 50L, 42L, 37L, 29L, 54L, 4L, 29L, 47L, 51L, 58L, 10L, 29L, 36L, 16L, 9L, 54L, 36L, 19L, 49L, 59L, 39L, 6L, 35L, 25L, 52L, 3L, 47L, 52L, 51L, 26L, 65L, 23L, 35L, 45L, 55L, 45L, 9L, 19L, 32L, 49L, 47L, 45L, 7L, 31L, 24L, 7L, 21L, 45L, 52L, 57L, 37L, 56L, 39L, 26L, 46L, 35L, 35L, 4L, 20L, 21L, 45L, 23L, 20L, 41L, 23L, 33L, 33L, 32L, 60L, 43L, 27L, 56L, 38L, 44L, 35L, 14L, 58L, 50L, 29L, 25L, 15L, 10L, 57L, 61L, 46L, 43L, 23L, 29L, 57L, 24L, 32L, 36L, 33L, 34L, 31L, 60L, 4L, 42L, 43L, 41L, 51L, 29L, 10L, 29L, 48L, 29L, 37L, 62L, 17L, 37L, 45L, 17L, 47L, 53L, 10L, 35L, 8L, 25L, 32L, 51L, 46L, 39L, 46L, 48L, 4L, 35L, 34L, 37L, 3L, 6L, 74L, 13L, 60L, 36L, 1L, 33L, 13L, 23L, 42L, 60L, 39L, 66L, 49L, 50L, 57L, 41L, 16L, 23L, 28L, 6L, 45L, 53L, 21L, 26L, 40L, 21L, 34L, 37L, 6L, 50L, 48L, 28L, 62L, 50L, 48L, 28L, 14L, 31L, 44L, 17L, 26L, 46L, 17L, 11L, 55L, 24L, 33L, 30L, 52L, 22L, 40L, 43L, 29L, 36L, 60L, 5L, 45L, 33L, 44L, 35L, 32L, 19L, 51L, 19L, 29L, 24L, 35L, 28L, 42L, 6L, 42L, 63L, 19L, 11L, 56L, 48L, 8L, 12L, 30L, 12L, 48L, 56L, 20L, 54L, 32L, 64L, 42L, 44L, 28L, 26L, 42L, 48L, 33L, 46L, 46L, 23L, 28L, 64L, 25L, 19L, 26L, 3L, 31L, 49L, 40L, 65L, 28L, 20L, 47L, 24L, 71L, 13L, 34L, 48L, 27L, 43L, 1L, 28L, 56L, 24L, 25L, 29L, 43L, 54L, 55L, 29L, 38L, 56L, 27L, 72L, 47L, 25L, 34L, 23L, 15L, 37L, 18L, 55L, 49L, 39L, 32L, 54L, 14L, 34L, 14L, 21L, 3L, 56L, 24L, 32L, 38L, 50L, 68L, 44L, 12L, 30L, 29L, 58L, 31L, 51L, 33L, 38L, 48L, 27L, 55L, 62L, 12L, 29L, 71L, 38L, 61L, 48L, 45L, 55L, 23L, 58L, 37L, 55L, 5L, 51L, 20L, 10L, 30L, 60L, 39L, 40L, 21L, 44L, 16L, 25L, 15L, 47L, 18L, 53L, 48L, 54L, 36L, 62L, 33L, 15L, 16L, 59L, 15L, 37L, 33L, 61L, 17L, 17L, 57L, 54L, 22L, 56L, 42L, 22L, 27L, 15L, 27L, 64L, 31L, 40L, 68L, 25L, 54L, 55L, 34L, 50L, 39L, 23L, 67L, 38L, 44L, 52L, 20L, 21L, 18L, 45L, 50L, 15L, 48L, 24L, 25L, 10L, 32L, 67L, 28L, 41L, 61L, 58L, 36L, 63L, 27L, 65L, 64L, 30L, 51L, 25L, 42L, 34L, 49L, 44L, 38L, 47L, 33L, 46L, 62L, 46L, 45L, 46L, 12L, 27L, 21L, 22L, 17L, 12L, 49L, 55L, 39L, 37L, 37L, 59L, 35L, 18L, 11L, 48L, 32L, 4L, 25L, 42L, 42L, 52L, 36L, 74L, 51L, 35L, 66L, 36L, 60L, 31L, 44L, 58L, 10L, 22L, 53L, 49L, 51L, 38L, 42L, 41L, 25L, 50L, 49L, 39L, 51L, 35L, 60L, 30L, 51L, 54L, 50L, 51L, 54L, 13L, 34L, 34L, 54L, 26L, 26L, 43L, 20L, 30L, 35L, 43L, 33L, 4L, 46L, 36L, 35L, 2L, 36L, 41L, 45L, 16L, 33L, 59L, 64L, 19L, 15L, 29L, 6L, 57L, 50L, 59L, 52L, 24L, 49L, 9L, 44L, 39L, 56L, 31L, 50L, 50L, 29L, 11L, 69L, 29L, 40L, 50L, 15L, 55L, 31L, 58L, 13L, 36L, 18L, 21L, 46L, 27L, 58L, 75L, 28L, 22L, 61L, 2L, 46L, 27L, 23L, 48L, 54L, 34L, 44L, 50L, 40L, 18L, 27L, 28L, 40L, 35L, 50L, 39L, 34L, 51L, 28L, 39L, 30L, 65L, 5L, 12L, 27L, 48L, 38L, 54L, 41L, 37L, 31L, 41L, 35L, 1L, 59L, 65L, 49L, 60L, 1L, 46L, 7L, 55L, 42L, 18L, 11L, 32L, 31L, 50L, 52L, 50L, 43L, 45L, 36L, 35L, 10L, 24L, 53L, 19L, 43L, 40L, 38L, 28L, 27L, 46L, 55L, 29L, 37L, 53L, 53L, 55L, 39L, 38L, 46L, 25L, 11L, 17L, 42L, 31L, 33L, 17L, 8L, 15L, 39L, 39L, 47L, 25L, 46L, 37L, 37L, 40L, 62L, 42L, 25L, 21L, 30L, 18L, 54L, 8L, 20L, 32L, 38L, 41L, 16L, 19L, 75L, 19L, 38L, 63L, 23L, 49L, 22L, 32L, 35L, 62L, 38L, 36L, 31L, 31L, 23L, 24L, 52L, 25L, 27L, 36L, 39L, 11L, 16L, 45L, 61L, 8L, 38L, 50L, 18L, 52L, 4L, 53L, 24L, 13L, 34L, 39L, 47L, 59L, 22L, 39L, 9L, 29L, 20L, 73L, 55L, 71L, 34L, 55L, 52L, 35L, 50L, 58L, 37L, 3L, 20L, 3L, 57L, 51L, 29L, 10L, 30L, 46L, 7L, 47L, 64L, 58L, 60L, 47L, 39L, 43L, 46L, 62L, 59L, 38L, 34L, 32L, 28L, 59L, 39L, 25L, 15L, 56L, 37L, 12L, 48L, 51L, 43L, 59L, 19L, 10L, 50L, 42L, 19L, 39L, 58L, 24L, 49L, 27L, 9L, 15L, 16L, 39L, 11L, 49L, 29L, 30L, 30L, 47L, 57L, 59L, 49L, 20L, 51L, 43L, 46L, 19L, 51L, 47L, 47L, 25L, 5L, 52L, 40L, 21L, 36L, 6L, 64L, 35L, 29L, 40L, 63L, 26L, 39L, 39L, 39L, 51L, 43L, 27L, 41L, 19L, 49L, 52L, 61L, 50L, 37L, 42L, 50L, 47L, 41L, 32L, 26L, 23L, 37L, 52L, 27L, 60L, 29L, 22L, 37L, 38L, 15L, 37L, 24L, 21L, 50L, 60L, 36L, 39L, 48L, 59L, 46L, 73L, 35L, 31L, 34L, 25L, 75L, 41L, 20L, 36L, 55L, 10L, 39L, 44L, 62L, 40L, 14L, 29L, 49L, 45L, 59L, 54L, 52L, 41L, 40L, 35L, 36L, 32L, 2L, 51L, 24L, 49L, 22L, 49L, 57L, 28L, 12L, 35L, 5L, 31L, 7L, 6L, 51L, 33L, 24L, 6L, 51L, 25L, 10L, 52L, 54L, 75L, 12L, 55L, 42L, 17L, 15L, 39L, 52L, 29L, 6L, 11L, 59L, 40L, 36L, 17L, 14L, 27L, 14L, 56L, 33L, 59L, 55L, 31L, 31L, 27L, 29L, 39L, 7L, 20L, 50L, 8L, 2L, 31L, 59L, 39L, 71L, 24L, 32L, 8L, 60L, 24L, 21L, 37L, 17L, 24L, 42L, 33L, 25L, 32L, 12L, 38L, 46L, 31L, 40L, 37L, 12L, 19L, 21L, 44L, 20L, 30L, 38L, 45L, 2L, 30L, 60L, 15L, 23L, 34L, 6L, 35L, 23L, 25L, 31L, 18L, 42L, 59L, 40L, 42L, 16L, 46L, 71L, 21L, 36L, 18L, 37L, 38L, 31L, 65L, 34L, 55L, 59L, 34L, 66L, 29L, 31L, 7L, 8L, 58L, 14L, 23L, 65L, 29L, 16L, 52L, 35L, 7L, 20L, 14L, 15L, 46L, 9L, 61L, 45L, 26L, 27L, 59L, 26L, 38L, 29L, 14L, 32L, 47L, 36L, 40L, 57L, 39L, 31L, 25L, 34L, 46L, 39L, 59L, 11L, 26L, 21L, 9L, 13L, 47L, 37L, 43L, 45L, 19L, 52L, 42L, 53L, 26L, 49L, 37L, 33L, 50L, 28L, 25L, 35L, 6L, 55L, 25L, 11L, 16L, 53L, 32L, 20L, 20L, 41L, 55L, 22L, 12L, 50L, 13L, 71L, 22L, 5L, 56L, 33L, 44L, 57L, 52L, 53L, 44L, 18L, 32L, 60L, 59L, 24L, 48L, 29L, 45L, 16L, 53L, 55L, 13L, 41L, 6L, 72L, 30L, 22L, 31L, 32L, 8L, 41L, 34L, 4L, 1L, 34L, 9L, 20L, 33L, 67L, 9L, 48L, 72L, 31L, 40L, 38L, 56L, 50L, 45L, 63L, 18L, 31L, 11L, 35L, 51L, 55L, 57L, 21L, 48L, 50L, 28L, 55L, 39L, 33L, 2L, 35L, 6L, 30L, 25L, 18L, 17L, 30L, 40L, 38L, 31L, 46L, 69L, 36L, 14L, 35L, 42L, 32L, 66L, 55L, 25L, 13L, 76L, 54L, 57L, 24L, 17L, 24L, 35L, 32L, 27L, 56L, 5L, 54L, 30L, 53L, 62L, 41L, 38L, 30L, 2L, 69L, 35L, 46L, 44L, 36L, 33L, 30L, 57L, 61L, 42L, 63L, 30L, 44L, 34L, 17L, 53L, 53L, 15L, 46L, 58L, 43L, 21L, 36L, 27L, 21L, 32L, 28L, 10L, 15L, 8L, 53L, 63L, 43L, 10L, 64L, 41L, 58L, 7L, 36L, 26L, 19L, 26L, 52L, 14L, 36L, 4L, 49L, 20L, 42L, 35L, 9L, 23L, 57L, 5L, 43L, 40L, 31L, 26L, 49L, 31L, 41L, 3L, 13L, 45L, 29L, 42L, 41L, 57L, 67L, 37L, 50L, 25L, 47L, 25L, 52L, 60L, 38L, 49L, 40L, 43L, 45L, 45L, 42L, 50L, 63L, 10L, 42L, 31L, 26L, 26L, 60L, 54L, 9L, 3L, 57L, 63L, 44L, 45L, 31L, 61L, 48L, 3L, 55L, 41L, 40L, 32L, 22L, 23L, 37L, 39L, 30L, 6L, 25L, 2L, 41L, 3L, 15L, 35L, 50L, 48L, 17L, 30L, 55L, 40L, 24L, 39L, 47L, 49L, 48L, 16L, 14L, 5L, 31L, 29L, 32L, 60L, 34L, 55L, 58L, 51L, 30L, 48L, 47L, 52L, 30L, 35L, 65L, 7L, 54L, 9L, 23L, 59L, 25L, 19L, 47L, 38L, 56L, 73L, 70L, 47L, 64L, 43L, 30L, 40L, 45L, 3L, 40L, 35L, 50L, 10L, 35L, 49L, 33L, 28L, 8L, 6L, 60L, 37L, 46L, 65L, 48L, 47L, 27L, 23L, 13L, 39L, 40L, 44L, 55L, 35L, 21L, 21L, 51L, 33L, 49L, 11L, 25L, 25L, 44L, 6L, 25L, 30L, 22L, 45L, 31L, 23L, 56L, 37L, 47L, 20L, 25L, 48L, 23L, 58L, 47L, 46L, 45L, 31L, 28L, 13L, 68L, 18L, 42L, 22L, 33L, 33L, 11L, 47L, 50L, 21L, 2L, 22L, 48L, 38L, 39L, 32L, 29L, 52L, 10L, 35L, 45L, 43L, 2L, 41L, 23L, 3L, 41L, 29L, 39L, 44L, 11L, 44L, 68L, 36L, 27L, 27L, 54L, 44L, 39L, 58L, 24L, 19L, 57L, 22L, 16L, 64L, 25L, 3L, 60L, 51L, 46L, 50L, 32L, 6L, 52L, 43L, 59L, 36L, 36L, 7L, 14L, 49L, 22L, 69L, 40L, 51L, 56L, 44L, 10L, 30L, 46L, 53L, 30L, 17L, 32L, 37L, 36L, 9L, 41L, 2L, 34L, 57L, 27L, 25L, 25L, 55L, 48L, 40L, 36L, 25L, 36L, 7L, 41L, 44L, 22L, 55L, 38L, 31L, 49L, 62L, 15L, 48L, 13L, 23L, 20L, 48L, 21L, 50L, 33L, 23L, 67L, 30L, 39L, 34L, 41L, 32L, 43L, 43L, 26L, 24L, 27L, 10L, 20L, 77L, 22L, 56L, 54L, 67L, 52L, 14L, 38L, 24L, 50L, 33L, 39L, 40L, 67L, 33L, 44L, 51L, 72L, 39L, 47L, 9L, 43L, 54L, 5L, 35L, 52L, 16L, 37L, 45L, 22L, 27L, 35L, 61L, 51L, 2L, 59L, 49L, 45L, 22L, 44L, 31L, 49L, 35L, 22L, 35L, 35L, 44L, 48L, 38L, 39L, 41L, 59L, 27L, 47L, 25L, 28L, 8L, 40L, 37L, 50L, 75L, 16L, 39L, 42L, 52L, 31L, 36L, 43L, 19L, 66L, 21L, 22L, 64L, 38L, 26L, 43L, 64L, 56L, 1L, 3L, 27L, 28L, 10L, 33L, 35L, 38L, 30L, 38L, 39L, 57L, 24L, 55L, 23L, 42L, 35L, 5L, 53L, 71L, 40L, 12L, 37L, 37L, 8L, 7L, 24L, 37L, 31L, 59L, 44L, 50L, 50L, 63L, 42L, 24L, 61L, 2L, 56L, 36L, 48L, 41L, 27L, 10L, 16L, 71L, 33L, 24L, 40L, 16L, 45L, 64L, 45L, 59L, 12L, 26L, 42L, 54L, 52L, 37L, 53L, 43L, 47L, 8L, 51L, 43L, 59L, 14L, 44L, 48L, 3L, 51L, 27L, 3L, 48L, 57L, 31L, 23L, 17L, 52L, 11L, 62L, 39L, 40L, 57L, 43L, 53L, 38L, 31L, 14L, 53L, 43L, 39L, 20L, 56L, 31L, 11L, 37L, 31L, 49L, 36L, 35L, 50L, 19L, 47L, 28L, 53L, 30L, 17L, 27L, 35L, 48L, 34L, 32L, 36L, 23L, 17L, 14L, 24L, 56L, 28L, 58L, 40L, 48L, 32L, 28L, 32L, 21L, 24L, 43L, 44L, 67L, 18L, 63L, 30L, 31L, 29L, 57L, 44L, 35L, 40L, 30L, 32L, 16L, 45L, 27L, 36L, 28L, 23L, 38L, 35L, 30L, 43L, 59L, 57L, 50L, 23L, 16L, 64L, 44L, 50L, 43L, 40L, 21L, 41L, 59L, 22L, 32L, 15L, 22L, 49L, 60L, 29L, 44L, 58L, 40L, 24L, 23L, 34L, 25L, 41L, 14L, 16L, 32L, 37L, 51L, 45L, 54L, 40L, 43L, 24L, 56L, 67L, 47L, 48L, 41L, 47L, 26L, 25L, 25L, 57L, 66L, 47L, 4L, 32L, 48L, 26L, 2L, 24L, 40L, 43L, 30L, 34L, 30L, 29L, 53L, 22L, 19L, 31L, 58L, 3L, 18L, 30L, 31L, 35L, 64L, 59L, 17L, 4L, 42L, 32L, 75L, 31L, 13L, 59L, 12L, 31L, 49L, 34L, 13L, 30L, 1L, 16L, 34L, 35L, 17L, 19L, 50L, 52L, 25L, 33L, 50L, 10L, 23L, 22L, 47L, 43L, 54L, 5L, 41L, 28L, 13L, 46L, 44L, 9L, 24L, 22L, 33L, 58L, 17L, 59L, 29L, 44L, 34L, 10L, 30L, 24L, 15L, 40L, 42L, 5L, 39L, 34L, 28L, 6L, 40L, 44L, 25L, 50L, 57L, 40L, 53L, 37L, 41L, 48L, 48L, 23L, 55L, 20L, 8L, 41L, 46L, 27L, 39L, 51L, 20L, 36L, 45L, 33L, 71L, 3L, 15L, 49L, 21L, 34L, 5L, 42L, 2L, 40L, 35L, 13L, 13L, 2L, 42L, 17L, 7L, 53L, 30L, 27L, 11L, 37L, 49L, 23L, 45L, 32L, 30L, 16L, 21L, 32L, 20L, 40L, 29L, 3L, 46L, 34L, 56L, 46L, 21L, 46L, 25L, 14L, 15L, 15L, 53L, 31L, 27L, 34L, 67L, 29L, 62L, 37L, 51L, 36L, 32L, 10L, 50L, 44L, 43L, 40L, 34L, 26L, 62L, 24L, 63L, 50L, 13L, 42L, 43L, 49L, 29L, 30L, 9L, 40L, 11L, 61L, 67L, 37L, 20L, 49L, 66L, 49L, 34L, 25L, 30L, 58L, 45L, 15L, 18L, 32L, 29L, 17L, 18L, 43L, 72L, 54L, 40L, 29L, 18L, 39L, 35L, 16L, 37L, 18L, 1L, 43L, 22L, 38L, 57L, 23L, 25L, 26L, 46L, 25L, 15L, 36L, 26L, 32L, 15L, 57L, 33L, 25L, 63L, 35L, 44L, 25L, 13L, 26L, 56L, 30L, 39L, 35L, 39L, 20L, 47L, 44L, 22L, 45L, 23L, 7L, 30L, 47L, 7L, 54L, 47L, 5L, 52L, 21L, 72L, 23L, 41L, 43L, 30L, 28L, 32L, 43L, 35L, 66L, 70L, 37L, 44L, 33L, 11L, 51L, 26L, 48L, 41L, 10L, 50L, 31L, 39L, 41L, 43L, 20L, 27L, 29L, 17L, 47L, 25L, 48L, 15L, 49L, 50L, 34L, 16L, 26L, 32L, 27L, 71L, 41L, 30L, 34L, 36L, 47L, 32L, 17L, 19L, 33L, 26L, 17L, 25L, 22L, 35L, 42L, 25L, 37L, 6L, 46L, 3L, 53L, 39L, 29L, 10L, 41L, 45L, 10L, 31L, 43L, 35L, 43L, 30L, 6L, 12L, 28L, 18L, 40L, 35L, 37L, 23L, 29L, 8L, 32L, 55L, 53L, 12L, 16L, 35L, 23L, 27L, 51L, 32L, 36L, 9L, 43L, 26L, 28L, 36L, 46L, 56L, 21L, 21L, 19L, 16L, 21L, 16L, 8L, 12L, 44L, 4L, 21L, 26L, 66L, 64L, 9L, 38L, 34L, 50L, 20L, 36L, 37L, 31L, 55L, 37L, 60L, 20L, 61L, 28L, 65L, 44L, 33L, 50L, 53L, 34L, 43L, 27L, 17L, 30L, 55L, 20L, 43L, 46L, 50L, 44L, 27L, 44L, 43L, 23L, 26L, 52L, 23L, 52L, 27L, 40L, 17L, 50L, 8L, 21L, 36L, 68L, 19L, 26L, 45L, 47L, 30L, 27L, 42L, 22L, 38L, 36L, 16L, 15L, 27L, 47L, 26L, 51L, 17L, 54L, 60L, 38L, 23L, 19L, 30L, 44L, 42L, 7L, 33L, 56L, 14L, 45L, 54L, 47L, 64L, 64L, 18L, 55L, 67L, 36L, 51L, 30L, 12L, 59L, 33L, 12L, 33L, 17L, 13L, 44L, 24L, 46L, 41L, 25L, 41L, 33L, 27L, 1L, 14L, 29L, 29L, 29L, 8L, 48L, 22L, 39L, 59L, 36L, 34L, 37L, 13L, 38L, 32L, 22L, 3L, 30L, 21L, 51L, 38L, 4L, 8L, 50L, 38L, 30L, 31L, 22L, 37L, 62L, 46L, 45L, 26L, 13L, 51L, 54L, 38L, 13L, 22L, 25L, 28L, 22L, 33L, 24L, 22L, 52L, 26L, 11L, 46L, 18L, 27L, 32L, 56L, 2L, 36L, 13L, 71L, 56L, 43L, 37L, 5L, 63L, 34L, 51L, 34L, 38L, 29L, 35L, 44L, 68L, 18L, 30L, 41L, 50L, 58L, 48L, 43L, 16L, 33L, 43L, 46L, 61L, 29L, 46L, 73L, 8L, 21L, 19L, 12L, 35L, 25L, 21L, 34L, 44L, 52L, 3L, 36L, 5L, 51L, 9L, 50L, 60L, 24L, 3L, 31L, 13L, 36L, 42L, 67L, 44L, 18L, 8L, 20L, 60L, 38L, 69L, 65L, 23L, 44L, 52L, 45L, 29L, 51L, 22L, 23L, 27L, 58L, 61L, 32L, 33L, 58L, 31L, 30L, 50L, 64L, 24L, 4L, 45L, 43L, 46L, 53L, 35L, 51L, 51L, 45L, 37L, 30L, 2L, 58L, 41L, 35L, 30L, 35L, 40L, 33L, 60L, 60L, 55L, 37L, 27L, 10L, 21L, 27L, 17L, 33L, 46L, 28L, 36L, 53L, 34L, 26L, 36L, 59L, 9L, 30L, 55L, 45L, 57L, 17L, 19L, 2L, 31L, 41L, 26L, 29L, 16L, 47L, 52L, 44L, 29L, 61L, 25L, 55L, 8L, 5L, 56L, 45L, 51L, 25L, 11L, 26L, 35L, 33L, 41L, 71L, 35L, 63L, 38L, 32L, 53L, 31L, 52L, 44L, 34L, 50L, 40L, 21L, 36L, 76L, 40L, 23L, 42L, 25L, 14L, 58L, 38L, 37L, 69L, 46L, 46L, 49L, 42L, 28L, 55L, 13L, 45L, 12L, 42L, 32L, 11L, 32L, 36L, 61L, 19L, 28L, 31L, 35L, 22L, 15L, 50L, 64L, 32L, 59L, 33L, 24L, 19L, 49L, 36L, 26L, 57L, 57L, 34L, 29L, 7L, 30L, 42L, 47L, 53L, 55L, 55L, 35L, 26L, 20L, 55L, 61L, 43L, 31L, 30L, 52L, 27L, 63L, 25L, 47L, 63L, 23L, 2L, 47L, 12L, 37L, 34L, 46L, 30L, 62L, 52L, 27L, 3L, 59L, 50L, 5L, 34L, 23L ), levels = c("16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "93", "N.C. "), class = "factor"), CIS.P3 = structure(c(3L, 3L, 3L, 3L, 3L, 2L, 1L, 3L, 2L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 2L, 2L, 3L, 3L, 2L, 1L, 2L, 1L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 1L, 2L, 3L, 1L, 2L, 2L, 2L, 3L, 3L, 2L, 1L, 3L, 1L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 1L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 1L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 2L, 1L, 2L, 3L, 3L, 2L, 1L, 3L, 1L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 3L, 1L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 2L, 3L, 2L, 3L, 3L, 3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L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L), levels = c("Mejor", "(NO LEER) Igual", "Peor", "N.S.", "N.C."), class = "factor")), class = "data.frame", row.names = c(NA, -2787L))
Maybe you want something like this using facet_wrap: set.seed(123) CIS_data_5 <- data.frame( CIS$CIS.P20, CIS$CIS.P3 ) CIS$P3 <- factor(CIS$CIS.P3, labels = c("Mejor", "(NO LEER) Igual", "Peor", "N.S.", "N.C.")) n <- as.numeric(c(CIS$CIS.P20)) P20 <- sample(n, 2787, replace = TRUE, prob = NULL) P20labs <- c("16-29", "30-44", "45-64", ">65", "N.C.") cut_points <- c(16, 30, 45, 65, Inf) i <- findInterval(P20, cut_points) P20_fac <- P20labs[i] P20_fac[is.na(P20)] <- P20labs[length(P20labs)] P20_fac <- factor(P20_fac, levels = P20labs) library(dplyr) library(ggplot2) data.frame(P3 = CIS$P3, P20_fac = P20_fac) %>% ggplot(aes(x = P20_fac)) + geom_bar() + coord_flip() + facet_wrap(~P3) Created on 2022-09-25 with reprex v2.0.2
Gtsummary output with mgcv gam
I have the following data set: structure(list(Age = c(83L, 26L, 26L, 20L, 20L, 77L, 32L, 21L, 15L, 75L, 27L, 81L, 81L, 15L, 24L, 16L, 35L, 27L, 30L, 31L, 24L, 24L, 31L, 79L, 30L, 19L, 20L, 42L, 62L, 83L, 79L, 18L, 26L, 66L, 23L, 83L, 77L, 80L, 57L, 42L, 32L, 76L, 85L, 29L, 65L, 79L, 9L, 34L, 20L, 16L, 34L, 22L, 19L, 23L, 25L, 14L, 53L, 28L, 79L, 22L, 22L, 21L, 82L, 81L, 16L, 19L, 77L, 15L, 18L, 15L, 78L, 24L, 16L, 14L, 29L, 18L, 50L, 17L, 43L, 8L, 14L, 85L, 31L, 20L, 30L, 23L, 78L, 29L, 6L, 61L, 14L, 22L, 10L, 83L, 15L, 13L, 15L, 15L, 29L, 8L, 9L, 15L, 8L, 9L, 15L, 9L, 34L, 8L, 9L, 9L, 16L, 8L, 25L, 21L, 23L, 13L, 56L, 10L, 7L, 27L, 8L, 8L, 8L, 8L, 80L, 80L, 6L, 15L, 42L, 25L, 23L, 21L, 8L, 11L, 43L, 69L, 34L, 34L, 14L, 12L, 10L, 22L, 78L, 16L, 76L, 12L, 10L, 16L, 6L, 13L, 66L, 11L, 26L, 12L, 16L, 13L, 24L, 76L, 10L, 65L, 20L, 13L, 25L, 14L, 12L, 15L, 43L, 51L, 27L, 15L, 24L, 34L, 63L, 17L, 15L, 9L, 12L, 17L, 82L, 75L, 24L, 44L, 69L, 11L, 10L, 12L, 10L, 10L, 70L, 54L, 45L, 42L, 84L, 54L, 23L, 23L, 14L, 81L, 17L, 42L, 44L, 16L, 15L, 43L, 45L, 50L, 53L, 23L, 53L, 49L, 13L, 69L, 14L, 65L, 14L, 13L, 22L, 67L, 59L, 52L, 54L, 44L, 78L, 62L, 69L, 10L, 63L, 57L, 22L, 12L, 62L, 9L, 82L, 53L, 54L, 66L, 49L, 63L, 51L, 9L, 45L, 49L, 77L, 49L, 61L, 62L, 57L, 67L, 16L, 65L, 75L, 45L, 16L, 55L, 17L, 64L, 67L, 56L, 52L, 63L, 10L, 62L, 14L, 66L, 68L, 15L, 13L, 43L, 47L, 55L, 69L, 21L, 67L, 34L, 52L, 15L, 31L, 64L, 55L, 13L, 48L, 71L, 64L, 13L, 25L, 34L, 50L, 61L, 70L, 33L, 57L, 51L, 46L, 57L, 69L, 46L, 8L, 11L, 46L, 71L, 33L, 38L, 56L, 17L, 29L, 28L, 6L, 8L), Sex = structure(c(1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L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581, -0.0551328105526693, 0.582747640515478, 1.94179165777054, 1.7064645993306, 2.37250948563045, 1.015775832203, 1.36189033704266, -1.05640048650493, 0.184814975542474, -0.143366705302007, 1.81560178585347, 2.06325078470728, -0.473088628698217, 0.414641167726219, 0.199887349084444, -0.60620959209809, -0.17879228399189, -1.03483709078065, -1.43497010225613, -0.958595084469815, 1.0203965598582, -1.44731404613503, -1.17191867788498, -2.02547709312595, -1.22395687266857, -1.09952727795348, -1.0830246791849, 1.21072653232248, 1.69997357714829, 1.53648783201423, 0.208688735094353, 0.0862394522314924, 1.08662698958276, -0.731299290763917, 2.29307697689102, -0.660008064083659, -1.21425334459264, 1.10191939777498, -2.0957781638801, -1.14947514355972, 0.248845058764562, 2.6526135953958, 0.197907037232212, -0.222469162066061, 1.92880961340592, 1.23328008397287, -1.17288683034607, -0.308282675662673, -1.02603570477074, -1.32647101621898, -1.58316343919798, -0.0440210607151585, -0.388375288352846, -0.935491446193807, -0.63789458173376, 0.454577456746182, -1.77391147749773, 0.709267564407921, 0.125735671950958, -0.821073428064989, -0.126534054558056, 0.519597695894384, 0.188005477971066, 0.212319306823438, -1.45807374053215, 1.5856655763446, -1.25641198358011, -0.910847565366061, -1.1191763722206, 0.25300371365424, -0.750772357310844, 0.37932560636146, -0.871791414947088, -1.92771569802088, -1.1752191976387, 0.210449012296334, -0.347778895382139, -0.132254955464496, 0.953616043508016, -0.0862677135627232, 0.838977990728951, -1.8993092246739, -0.0254281327692267, 0.298022803094927, -1.21559555595915, 0.0134079829994995, -0.763094297724715, 0.334768589686298, -1.12568939786794, -2.11786964276497, -0.0434709740895377, 0.388237009696492, 1.30050066962355, -0.260645173884043, -0.60620959209809, 1.05945271027717, -0.275717547426008, -0.0238878902174922, 0.496604074943496, 0.534009965485611, -0.692903244295693, -0.566933407028871, 0.125625654625835, -0.518305749324122, 1.79381835547894, -0.790708646330802, -0.227860010997131, 0.347420582075538, 0.784189362817269, -0.660118081408782, 1.29962053102256, -0.561652575422924, -0.710395998990384, -1.29315777017148, -0.457356151205503, -1.01756437073621, 0.146528946399368, -1.07136284272178, -1.42968927065019, 0.798601632408495, -0.799730066990963, -0.431348055546223, 0.569545561500617, 2.32168148142323, 0.472070211440872, 1.65145593676866, -0.814142336582189, -0.544489872703603, -0.315433801795725, 0.382626126115175, -0.623812364117908, 0.216279930527897, -0.606099574772967, -0.367207954999011, 0.719829227619811, -0.749122097433987, 0.934693063586709, -0.79026857703031, -0.371872689584264, 0.0769979969210905, -0.793899148759394, 1.50414273842782, 0.730280873506577, -0.290569886317732, 0.303743704001367, 0.390877425499463, -1.00359217044547, -0.534918365417827, 0.325967203676389, 0.129036191704673, 0.34434009697207, -0.141386393449775, -0.363401355549725, -0.395416397160769, -0.0235578382421178, -1.13583299524436, 1.16781977552417, -1.31890182425046, 0.139377820266317, 0.0160483988024708, 0.481311666751279, -1.05475022662807, 0.839858129329941, 0.652498624644007, -0.350199276534864, -0.262075399110649, 0.178543988010412, -1.13198238886502, -0.05117218684821, -1.29678834190056, 0.429603523943066, 1.05098137624263, -0.956504755292464, 0.502765045150433, -0.81678275238516, -1.50263075720731, -0.826684311646306, 2.40100397283753, 2.06633126981075, -0.470558230220369, 0.484942238480364, 0.822035322659877, 0.143888530596397, 0.384056351341786, -0.63580425255641, 0.358422314587926, -0.372422776209885, 0.0607154328027556, -0.113221958218067, 1.02710761669075, -0.349649189909243, 2.27195365046724, -0.507634068787109, -0.326105482332738, -1.0396778530861, 1.06484355920824, 1.32151397872221, -0.185173288849074, -0.651888785489516, -0.171311105883464, -0.104200537557911, -0.693673365571561, -1.26609350819101, 0.411230630647381, -0.929770545287362, -0.481009876107135, 0.386146680519137, 0.0482834750637615, -0.198265350538812, 0.790020281048832, 0.926001694901924, -1.08918564939184, 0.50298507980068, -0.0694350628187722, 1.04966116834114, 0.00878725534429612, 1.48742010500899, 0.750194009353997, 0.423772605711498, -0.596418050162068, -0.652636903300361, -0.308942779613417, 0.314437388003408, 0.679562886624478, -1.24312189070515, -0.432712270377761, 0.00427654501421597, -0.197935298563442, 0.228821905592019, 1.06957430418856, -1.61612462980509, 1.9499329398297, -0.263285589687014, 0.156430505660519, -0.322254875953402, -0.451085163673446, -0.35526007349056, 0.10780284795577, 0.408700232169533, -0.957604928543701, -1.05662052115517, 1.00345389178912, -0.238751726184391, 0.300003114947154, -0.397946795638617, -0.0802167606809086, 0.943714484246865, 1.10973062785877, 1.76279346979401, 1.62087112038423, 0.25533608094687, 0.226841593739787, 0.869672824438507, -1.44960240649761, -0.450315042397579, -0.199629565370345, 0.29813282042005, 0.760425620590513, 1.87391096816911, -0.454275666102039, -0.0559029318285365, -0.343048150401812, -1.01371376435687, 0.68880434193488, -0.29222014619459, 1.16132875334186, -1.95715633422403, -0.534368278792206, -0.560112332871189, 1.84508642898666, -1.19150176175703, -0.772203732244971, -0.3443683583033, -1.45684154649076, -0.633823940704178, -1.77454957798344, 0.279539892474118, -0.875532004001301, 1.26001429397797, -0.536590628759707, 2.1869102581465, 0.211109116247078, 0.130246382281038, -0.355810160116181, -0.898085555651692, -0.429741802599415, 1.13360438741065, 1.61338994227581, 0.588688576072169, 0.454137387445685, 0.747113524250528, 0.460848444278238, -0.38177424884541, -0.169990897981981, -0.747361820232001, -0.760123829946369, 0.208028631143609, -1.28748087619509, 2.33950428809329, -0.973029357526068, -1.06091119683501, 0.917530360867389, -0.35041931118511, -1.90613029883158, -1.15057531681095, 0.65348878057012, 0.43147381847017 )), row.names = c(NA, -308L), class = c("tbl_df", "tbl", "data.frame")) I am using this gam model: m1 <- gam(mean_AD_scaled ~ s(Age, bs = 'ad', k = -1) + Sex + ti(Age, by = Sex, bs ='fs'), data = DF, method = 'REML', family = gaussian) Output: Family: gaussian Link function: identity Formula: mean_AD_scaled ~ s(Age, bs = "ad", k = -1) + Sex + ti(Age, by = Sex, bs = "fs") Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04691 0.06976 0.672 0.502 SexFemale -0.12950 0.09428 -1.374 0.171 Approximate significance of smooth terms: edf Ref.df F p-value s(Age) 2.980 3.959 8.72 2.24e-06 *** ti(Age):SexMale 2.391 2.873 23.47 < 2e-16 *** ti(Age):SexFemale 1.000 1.000 43.40 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Rank: 48/49 R-sq.(adj) = 0.34 Deviance explained = 35.6% -REML = 375.4 Scale est. = 0.63867 n = 308 But when I use gtsummary, I get a repeated value for each gender 'interaction': tbl_regression(m1, tidy_fun = tidy_gam) I see the following in a publication, which I am trying to replicate with gender and age: I am not sure how to fix this. My goal is to print a table for a manuscript so any other gam-related information that can be added like edf and R^2.
I think you've found a bug in the handling of these types of interactions. While we work on a fix to the bug, this code should get you what you need. Thanks library(gtsummary) #> #BlackLivesMatter library(mgcv) packageVersion("gtsummary") #> [1] ‘1.5.2’ m1 <- gam(marker ~ s(age, bs = 'ad', k = -1) + grade + ti(age, by = grade, bs ='fs'), data = gtsummary::trial, method = 'REML', family = gaussian) tbl_regression(m1, tidy_fun = gtsummary::tidy_gam) %>% modify_table_body( ~ .x %>% dplyr::select(-n_obs) %>% dplyr::distinct() ) %>% as_kable() # convert to kable to display on SO Characteristic Beta 95% CI p-value Grade I — — II -0.39 -0.70, -0.08 0.014 III -0.13 -0.43, 0.18 0.4 s(age) >0.9 ti(age):gradeI 0.6 ti(age):gradeII >0.9 ti(age):gradeIII 0.6 Created on 2022-02-21 by the reprex package (v2.0.1)
Broom::tidy error with dataframe of nnet::multinom models
I am generating multinom models using nnet, with a model fitted for each city in the dataset. When I attempt to use tidy with these models, I get the following error: Error in probs[i, -1, drop = FALSE] : subscript out of bounds However, if I produce a model for each City separately, and then use tidy I do not receive an error for any of the models. I am also able to use glace without an error. What might be causing this error? library(broom) library(dplyr) library(nnet) dfstack <- structure(list(Var1 = c(73L, 71L, 66L, 75L, 96L, 98L, 98L, 65L, 75L, 74L, 71L, 98L, 100L, 87L, 78L, 50L, 73L, 82L, 70L, 70L, 31L, 34L, 32L, 100L, 100L, 100L, 54L, 51L, 36L, 48L, 66L, 60L, 59L, 72L, 76L, 90L, 85L, 76L, 55L, 53L, 42L, 54L, 54L, 10L, 34L, 18L, 6L, 16L, 63L, 41L, 68L, 55L, 52L, 57L, 64L, 61L, 68L, 44L, 33L, 19L, 38L, 54L, 44L, 87L, 100L, 100L, 63L, 75L, 76L, 100L, 100L, 64L, 95L, 90L, 99L, 98L, 87L, 62L, 62L, 88L, 79L, 85L), Status = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("A", "B", "C"), class = "factor"), City = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Denver", "Miami", "NYC"), class = "factor"), ID = structure(c(52L, 63L, 74L, 77L, 78L, 79L, 80L, 81L, 82L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 64L, 31L, 42L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 32L, 1L, 12L, 23L, 25L, 26L, 27L, 28L, 29L, 30L, 2L, 3L, 4L, 5L, 65L, 66L, 67L, 68L, 69L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 70L, 71L, 72L, 73L, 75L, 76L, 41L, 43L, 44L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 24L), .Label = c("Denver1", "Denver10", "Denver11", "Denver12", "Denver13", "Denver14", "Denver15", "Denver16", "Denver17", "Denver18", "Denver19", "Denver2", "Denver20", "Denver21", "Denver22", "Denver23", "Denver24", "Denver25", "Denver26", "Denver27", "Denver28", "Denver29", "Denver3", "Denver30", "Denver4", "Denver5", "Denver6", "Denver7", "Denver8", "Denver9", "Miami1", "Miami10", "Miami11", "Miami12", "Miami13", "Miami14", "Miami15", "Miami16", "Miami17", "Miami18", "Miami19", "Miami2", "Miami20", "Miami21", "Miami3", "Miami4", "Miami5", "Miami6", "Miami7", "Miami8", "Miami9", "NYC1", "NYC10", "NYC11", "NYC12", "NYC13", "NYC14", "NYC15", "NYC16", "NYC17", "NYC18", "NYC19", "NYC2", "NYC20", "NYC21", "NYC22", "NYC23", "NYC24", "NYC25", "NYC26", "NYC27", "NYC28", "NYC29", "NYC3", "NYC30", "NYC31", "NYC4", "NYC5", "NYC6", "NYC7", "NYC8", "NYC9"), class = "factor")), class = "data.frame", row.names = c(NA, -82L), .Names = c("Var1", "Status", "City", "ID")) Model.List <- dfstack %>% group_by(City) %>% do(modfits = multinom(Status~Var1, data=.)) tidy(Model.List, modfits) # produces error glance(Model.List, modfits) # no error # no error when each city on its own df1 <- dfstack %>% filter(City == "NYC") %>% do(modfit1 = multinom(Status~Var1, data=.)) tidy(df1, modfit1) df2 <- dfstack %>% filter(City == "Miami") %>% do(modfit1 = multinom(Status~Var1, data=.)) tidy(df2, modfit1) df3 <- dfstack %>% filter(City == "Denver") %>% do(modfit1 = multinom(Status~Var1, data=.)) tidy(df3, modfit1)
Don't ask me to explain why, but I figured it out. tidy.multinom calls summary.multinom which calls vcov.multinom which calls multinomHess. The error was being generated down in multinomHess, which is only run when the Hessian matrix is not generated in the original call to multinom. That is to say, you don't necessarily need to spend the time calculating the Hessian matrix if you don't intend to use the summary object. For some reason, when the multinom objects are formed within the do call, summary.multinom is unable to calculate the Hessian matrix. This can be circumvented by calling multinom with Hess = TRUE. See below: Model.List <- dfstack %>% group_by(City) %>% do(modfits = multinom(Status~Var1, data=., Hess = TRUE)) tidy(Model.List, modfits) glance(Model.List, modfits) In your original code, glance did not cast an error because glance.multinom does not rely on summary.multinom.
dplyr n_distinct() in filter takes forever where as base length(unique()) works like charm
I have a data frame such as this: structure(list(x = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 21L, 22L, 22L, 23L, 23L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L, 34L, 34L, 35L, 35L, 36L, 36L, 37L, 37L, 38L, 38L, 39L, 39L, 40L, 40L, 41L, 41L, 42L, 42L, 43L, 43L, 44L, 44L, 45L, 45L, 46L, 46L, 47L, 47L, 48L, 48L, 49L, 49L, 50L, 50L, 51L, 51L, 52L, 52L, 53L, 53L, 54L, 54L, 55L, 55L, 56L, 56L, 57L, 57L, 58L, 58L, 59L, 59L, 60L, 60L, 61L, 61L, 62L, 62L, 63L, 63L, 64L, 64L, 65L, 65L, 66L, 66L, 67L, 67L, 68L, 68L, 69L, 69L, 70L, 70L, 71L, 71L, 72L, 72L, 73L, 73L, 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= c("one", "two"), class = "factor")), class = "data.frame", row.names = c(NA, -200L), .Names = c("x", "y")) I am trying to filter groups of x that have two distinct y values using: library(dplyr) df %>% group_by(x) %>% filter(n_distinct(y) > 1) On a large data set, this almost never finishes. Changing to this works reasonably fast for the full data set: library(dplyr) df %>% group_by(x) %>% filter(length(unique(y)) > 1) Any idea why n_distinct() is super slow to never finishing?
Error in package msm: *** caught segfault *** 'memory not mapped'
I am trying to run a multistate model using the package msm and I am encountering the following error: *** caught segfault *** address 0x607c00032c60, cause 'memory not mapped' The data dat.long <- structure(list(id = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 11L, 11L, 11L, 12L, 12L, 12L, 13L, 13L, 13L, 14L, 14L, 14L, 15L, 15L, 15L, 16L, 16L, 16L, 17L, 17L, 17L, 18L, 18L, 18L, 19L, 19L, 19L, 20L, 20L, 20L, 21L, 21L, 21L, 22L, 22L, 22L, 23L, 23L, 23L, 24L, 24L, 24L, 25L, 25L, 25L, 26L, 26L, 26L, 27L, 27L, 27L, 28L, 28L, 28L, 29L, 29L, 29L, 30L, 30L, 30L, 31L, 31L, 31L, 32L, 32L, 32L, 33L, 33L, 33L, 34L, 34L, 34L, 35L, 35L, 35L, 36L, 36L, 36L, 37L, 37L, 37L, 38L, 38L, 38L, 39L, 39L, 39L, 40L, 40L, 40L, 41L, 41L, 41L, 42L, 42L, 42L, 43L, 43L, 43L, 44L, 44L, 44L, 45L, 45L, 45L, 46L, 46L, 46L, 47L, 47L, 47L, 48L, 48L, 48L, 49L, 49L, 49L, 50L, 50L, 50L, 51L, 51L, 51L, 52L, 52L, 52L, 53L, 53L, 53L, 54L, 54L, 54L, 55L, 55L, 55L, 56L, 56L, 56L, 57L, 57L, 57L, 58L, 58L, 58L, 59L, 59L, 59L, 60L, 60L, 60L, 61L, 61L, 61L, 62L, 62L, 62L, 63L, 63L, 63L, 64L, 64L, 64L, 65L, 65L, 65L, 66L, 66L, 66L, 67L, 67L, 67L, 68L, 68L, 68L, 69L, 69L, 69L, 70L, 70L, 70L, 71L, 71L, 71L, 72L, 72L, 72L, 73L, 73L, 73L, 74L, 74L, 74L, 75L, 75L, 75L, 76L, 76L, 76L, 77L, 77L, 77L, 78L, 78L, 78L, 79L, 79L, 79L, 80L, 80L, 80L, 81L, 81L, 81L, 82L, 82L, 82L, 83L, 83L, 83L, 84L, 84L, 84L, 85L, 85L, 85L, 86L, 86L, 86L, 87L, 87L, 87L, 88L, 88L, 88L, 89L, 89L, 89L, 90L, 90L, 90L, 91L, 91L, 91L, 92L, 92L, 92L, 93L, 93L, 93L, 94L, 94L, 94L, 95L, 95L, 95L, 96L, 96L, 96L, 97L, 97L, 97L, 98L, 98L, 98L, 99L, 99L, 99L), time = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), age = c(63L, 67L, 71L, 65L, 69L, 73L, 60L, 64L, 69L, 62L, 65L, 69L, 64L, 68L, 72L, 64L, 68L, 72L, 64L, 68L, 72L, 64L, 68L, 72L, 64L, 68L, 73L, 65L, 69L, 73L, 61L, 65L, 68L, 63L, 67L, 72L, 64L, 69L, 73L, 61L, 65L, 69L, 61L, 65L, 69L, 64L, 68L, 72L, 63L, 67L, 71L, 61L, 65L, 69L, 64L, 68L, 72L, 65L, 69L, 73L, 63L, 67L, 71L, 61L, 64L, 68L, 63L, 67L, 71L, 63L, 68L, 72L, 62L, 66L, 70L, 64L, 68L, 72L, 62L, 66L, 70L, 65L, 69L, 73L, 63L, 66L, 70L, 62L, 66L, 70L, 62L, 65L, 70L, 62L, 66L, 70L, 63L, 67L, 71L, 62L, 66L, 71L, 62L, 66L, 70L, 63L, 67L, 71L, 64L, 67L, 72L, 61L, 65L, 69L, 64L, 67L, 71L, 64L, 69L, 72L, 62L, 66L, 70L, 62L, 66L, 70L, 63L, 67L, 71L, 64L, 68L, 72L, 62L, 66L, 70L, 60L, 64L, 68L, 63L, 67L, 71L, 64L, 68L, 73L, 64L, 68L, 72L, 64L, 68L, 72L, 64L, 68L, 71L, 62L, 65L, 69L, 61L, 65L, 69L, 64L, 68L, 72L, 60L, 65L, 69L, 62L, 66L, 70L, 60L, 64L, 68L, 63L, 67L, 71L, 63L, 67L, 71L, 64L, 68L, 72L, 65L, 69L, 73L, 61L, 65L, 69L, 63L, 67L, 71L, 63L, 67L, 71L, 62L, 67L, 71L, 64L, 68L, 72L, 64L, 68L, 72L, 63L, 67L, 71L, 64L, 68L, 72L, 64L, 68L, 72L, 62L, 66L, 71L, 61L, 65L, 69L, 63L, 68L, 72L, 60L, 65L, 69L, 61L, 65L, 69L, 63L, 68L, 72L, 62L, 67L, 70L, 64L, 68L, 73L, 61L, 65L, 69L, 62L, 66L, 70L, 62L, 65L, 70L, 61L, 65L, 69L, 64L, 68L, 72L, 62L, 66L, 70L, 61L, 65L, 69L, 61L, 66L, 70L, 63L, 67L, 71L, 61L, 65L, 70L, 62L, 67L, 71L, 60L, 64L, 69L, 61L, 66L, 70L, 61L, 65L, 69L, 62L, 67L, 72L, 63L, 67L, 71L, 60L, 64L, 69L, 61L, 65L, 69L, 65L, 69L, 73L, 62L, 66L, 70L, 60L, 64L, 68L), mci = structure(c(2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1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age_R2", "b_age_R2", "c_age"), mci = c("mci_w1", "mci_w2", "mci_w3")), .Names = c("age", "mci")), v.names = c("age", "mci"), idvar = "id", timevar = "time"), .Names = c("varying", "v.names", "idvar", "timevar")), row.names = c("1.1", "1.2", "1.3", "2.1", "2.2", "2.3", "3.1", "3.2", "3.3", "4.1", "4.2", "4.3", "5.1", "5.2", "5.3", "6.1", "6.2", "6.3", "7.1", "7.2", "7.3", "8.1", "8.2", "8.3", "9.1", "9.2", "9.3", "10.1", "10.2", "10.3", "11.1", "11.2", "11.3", "12.1", "12.2", "12.3", "13.1", "13.2", "13.3", "14.1", "14.2", "14.3", "15.1", "15.2", "15.3", "16.1", "16.2", "16.3", "17.1", "17.2", "17.3", "18.1", "18.2", "18.3", "19.1", "19.2", "19.3", "20.1", "20.2", "20.3", "21.1", "21.2", "21.3", "22.1", "22.2", "22.3", "23.1", "23.2", "23.3", "24.1", "24.2", "24.3", "25.1", "25.2", "25.3", "26.1", "26.2", "26.3", "27.1", "27.2", "27.3", "28.1", "28.2", "28.3", "29.1", "29.2", "29.3", "30.1", "30.2", "30.3", "31.1", "31.2", "31.3", "32.1", "32.2", "32.3", "33.1", "33.2", "33.3", "34.1", "34.2", "34.3", "35.1", "35.2", "35.3", "36.1", "36.2", "36.3", "37.1", "37.2", "37.3", "38.1", "38.2", "38.3", "39.1", "39.2", "39.3", "40.1", "40.2", "40.3", "41.1", "41.2", "41.3", "42.1", "42.2", "42.3", "43.1", "43.2", "43.3", "44.1", "44.2", "44.3", "45.1", "45.2", "45.3", "46.1", "46.2", "46.3", "47.1", "47.2", "47.3", "48.1", "48.2", "48.3", "49.1", "49.2", "49.3", "50.1", "50.2", "50.3", "51.1", "51.2", "51.3", "52.1", "52.2", "52.3", "53.1", "53.2", "53.3", "54.1", "54.2", "54.3", "55.1", "55.2", "55.3", "56.1", "56.2", "56.3", "57.1", "57.2", "57.3", "58.1", "58.2", "58.3", "59.1", "59.2", "59.3", "60.1", "60.2", "60.3", "61.1", "61.2", "61.3", "62.1", "62.2", "62.3", "63.1", "63.2", "63.3", "64.1", "64.2", "64.3", "65.1", "65.2", "65.3", "66.1", "66.2", "66.3", "67.1", "67.2", "67.3", "68.1", "68.2", "68.3", "69.1", "69.2", "69.3", "70.1", "70.2", "70.3", "71.1", "71.2", "71.3", "72.1", "72.2", "72.3", "73.1", "73.2", "73.3", "74.1", "74.2", "74.3", "75.1", "75.2", "75.3", "76.1", "76.2", "76.3", "77.1", "77.2", "77.3", "78.1", "78.2", "78.3", "79.1", "79.2", "79.3", "80.1", "80.2", "80.3", "81.1", "81.2", "81.3", "82.1", "82.2", "82.3", "83.1", "83.2", "83.3", "84.1", "84.2", "84.3", "85.1", "85.2", "85.3", "86.1", "86.2", "86.3", "87.1", "87.2", "87.3", "88.1", "88.2", "88.3", "89.1", "89.2", "89.3", "90.1", "90.2", "90.3", "91.1", "91.2", "91.3", "92.1", "92.2", "92.3", "93.1", "93.2", "93.3", "94.1", "94.2", "94.3", "95.1", "95.2", "95.3", "96.1", "96.2", "96.3", "97.1", "97.2", "97.3", "98.1", "98.2", "98.3", "99.1", "99.2", "99.3"), class = "data.frame") I then run the multistate model as follows. library(msm) #construct the qmatrix(all transitions are allowed.) Q <- matrix(c(1,1,1,1), nrow = 2, ncol = 2, byrow=TRUE, dimnames=list(from=1:2,to=1:2)) #specify the initial values crudeinits <- crudeinits.msm(mci ~ age, subject=id, data=dat.long, qmatrix=Q) #the model mci.msm <- msm(mci ~ age, subject = id, qmatrix = crudeinits, data = dat.long) This than results in the R session been terminated with the above error. I am currently unsure how to resolve this issue so any help would be appreciated. Thanks
After contacting the maintainer of the msm package the issue was resolved by redefining the state variable numeric rather than a factor. The full reply is below. Thanks for this report. This might be related to the state variable being a factor rather than numeric. I can make it work for me by redefining dat.long$mci <- as.numeric(dat.long$mci). I couldn't reproduce the crash, but it didn't converge with the state as a factor. I don't think it's documented explicitly, but factor states were supposed to work as long as their levels are named 1,2,.... So it's a bug, which seems to have been introduced in 1.4, but I'll fix it for the next release.