Questions tagged [r]

Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer, & (b) is not *just* about how to use `R`.

Filter by
Sorted by
Tagged with
1 vote
2 answers
10 views

Why are my test data R-squared's identical despite using different training data?

I'm fitting two linear models in R, one using a 'big' dataset, the other using a 'small' dataset which is a subset of the big dataset. When I calculate out-of-sample R-squared from the two models the ...
user avatar
  • 111
0 votes
0 answers
8 views

Standardization before clustering is always a good idea?

I'm performing k-means clustering based on 5 features with different scales and Mean > Median. So, I scaled the data before applying kmeans. The Average silhouette width is therefore maximized for ...
user avatar
  • 1
0 votes
0 answers
7 views

Problems with in Fisher exact test: results by fisher.test and oddratio function of epitools package

This is my data mydata <- matrix(c(86,1,14,0), nrow = 2, ncol = 2, byrow = TRUE) When using fisher.test in R give ...
user avatar
  • 115
0 votes
0 answers
5 views

Experience with Kruskal-Wallis versus Zero-Inflated Kruskal-Wallis as nonparametric alternative to one-way ANOVA

I have a data set of 1 categorical predictor (4 levels) and one non-negative continuous response variable (listed as "aphidleaf in histogram). The response variable is not count data and the ...
user avatar
  • 1
0 votes
1 answer
16 views

How to conduct Cox-regression with time-dependent covariate and estimate K-M plots (including log-rank test)?

I want to conduct a Cox-regression with time-dependent covariate and other control variables and estimate K-M plot with log-rank test result. I will take the heart transplant as an example, some ...
user avatar
1 vote
1 answer
19 views

ANOVA: RSS > TSS?

I am sure that this is a simple question, but I can't figure out what my mistake is. I am doing an ANOVA project using car::Anova. I presumed that the TSS would be ...
user avatar
0 votes
0 answers
14 views

How to trust results of GAM in R

EDITED: I'm new to GAM's and am looking for some advice on if I can trust my model or not. My dataset (n=200) is examining how a whole suite of environmental variables (15) impact the likelihood of ...
user avatar
0 votes
1 answer
23 views

Should I use ordered factor in glm model in R?

I want to fit a generalized linear model (logistic regression) to Titanic dataset. In EDA stage I transformed a variable (Pclass) to ordered factor. Before passing ...
user avatar
0 votes
0 answers
4 views

Repeated measures covariants in linear model and not outcome

I have a dataset which contains a categorical outcome, 2 repeated measures over time for the same subject and several covariates ...
user avatar
0 votes
1 answer
40 views

Transformations for zero inflated non-negative continuous response variable in R

Initially, this was going to be a simple analysis of variance (ANOVA) with a categorical predictor (4 levels) and a non-negative continuous response variable (number of aphids on leaves from four ...
user avatar
  • 1
1 vote
0 answers
11 views

Simple regression on subsets vs ANCOVA with interaction term

I'm attempting to predict a continuous variable as a function of one continuous variable and one categorical variable. This led me to an ANCOVA, but I've violated the homogeneity of regression slopes ...
user avatar
  • 198
0 votes
0 answers
11 views

Effect Sizes for Unstandardized Estimates in Hurdle Models? [closed]

I used the pscl package in R to run a hurdle model on count data. The output for the hurdle model provides an unstandardized estimate, standard error, Z score, and probability (> absolute value of ...
user avatar
0 votes
0 answers
12 views

Interpolation of a multidimensional grid

I am using the ks package to make density kernels for 2D up to 4D data. ks is an excellent package. Lets say I have $(X,Y)$ ...
user avatar
-1 votes
0 answers
27 views

Simulating the error term with an AR(2) model

I'm working on some simulations in R where I have a time series in the format $$y_t=\mu_t+e_t$$ where $\mu_t$ is a trend function that I have defined as $\mu_t=5*t+4*sin(2t)$ and where $t$ goes from $ ...
user avatar
2 votes
0 answers
30 views

Recreating equation in R returns different value

I am trying to understand an equation that is used to determine sample size. To do this, I am re-creating the example from a tutorial in R. However, when I re-create the example in R I get a different ...
user avatar
0 votes
0 answers
5 views

How to choose gam base functions, family and splines and how to deal with non-convergence with gam (fam=ziplss, mgcv)?

I am new to this forum and modelling in general. I will try to give a full overview of issue, so bear with me. I am modelling a the habitat use of herbivore species. I have observational data from ...
user avatar
  • 1
0 votes
0 answers
12 views

mixed effect with logistic regression not working as expected

I found a situation I cannot explain, and I would need some help from specialists. I am trying to create a Simpson paradox, but for a binary variable, and to solve it with mixed-effect models. This ...
user avatar
  • 211
0 votes
0 answers
9 views

Interpreting output of a pscl hurdle model in R

I've read several posts on interpreting the output summary of hurdle models, but I'm still struggling a bit to understand the output as its more complicated than models I'm used to. For my data, I'm ...
user avatar
1 vote
1 answer
65 views

Problems in chisq.test in R

I have two groups of samples, NGHC (n=14) and NHC (n=87). The result of the samples CO.05 should be 0 or 1. For example, the results can be ...
user avatar
  • 115
0 votes
0 answers
17 views

K-prototype in R: Error when including missing values

I want to cluster data that includes categorical (dummies and variables with multiple categories) and numerical variables (normalised) and a substantial amount of missing values. One reason why I want ...
user avatar
  • 1
0 votes
0 answers
15 views

Proving that one score is not dependent on the other - interval data - R - Spearman correlation?

I want to attempt to answer the following hypothesis A continuous scale (measured by an understanding score of 0-2) has a positive influence on consumers’ understanding of an eco-label (understanding ...
user avatar
0 votes
0 answers
15 views

Time Series: Predicting daily count sales data of three different products

I have a data set containing historic daily sales of 3 products pasta, nuts and yeast for one year (2020-01-01 - 2020-12-31). Pasta and nuts are from store 1, while yeast is from store 2. The ...
user avatar
  • 445
2 votes
1 answer
39 views

Why do arrows of PCA graph have different angles between biplot and ggplot functions?

I'm using R iris data to show my point: pca = prcomp(iris[,-5],scale=F) png('irisNS_biplot.png',600,600) biplot(pca) dev.off() ...
user avatar
  • 319
0 votes
0 answers
9 views

Error in nlrq R function and constraints to the argument [closed]

I've got a model to be estimated through the non-linear quantile regression method. The model is specified in such a way that I have 6 coefficients b1,b2,...,b6. I have constraints for my coefficients:...
user avatar
0 votes
0 answers
19 views

The math behind svyglm() when we have weights and clusters

I want to apply survey::svyglm() to a scenario that we need to get the robust standard error in both weights and clusters. There is an example in survey R package: ...
user avatar
0 votes
0 answers
24 views

Matrix Completion function in r [closed]

I want to write a matrix completion function for missing values. I am wondering why the correlation of the output with the true missing values is decreasing when I am increasing the number of ...
user avatar
  • 1
0 votes
0 answers
14 views

Are the classes between groups in a multiple-group latent class analysis related?

For example, if I run an LCA grouped by sex, and I get male class 1 and 2, and female class 1 and 2- do male class 1 and female class 1 relate in any way? Do they make up some larger/overall class 1, ...
user avatar
1 vote
2 answers
14 views

Machine Learning outcome with more than 2 categories-caret

I know that there are many algorithms for ML problems where the outcome has 2 categories. I am wondering kwon if there are algorithms that accept outcomes with more than 2 categories, especially in ...
user avatar
1 vote
1 answer
28 views

Is the 'Std. Error' provided by lmer in lme4 actually Standard Deviation?

I have been working with lmer in lme4, and wanted to construct a density curve of the slopes produced by my model (rather than just confidence intervals). The model output of lmer produces a slope, ...
user avatar
0 votes
1 answer
39 views

Generating data from a hypothetical model

Let say I have below model $y_{i,t} = 1 + X_1 + X_2 + {\gamma}_i + \epsilon_{i,t}, \epsilon_{i,t} \sim N \left(0, 1 \right), {\gamma}_i \sim N \left(0, \gamma \right)$ Here, the panel it is ...
user avatar
1 vote
2 answers
53 views

Cross-validation by hand in R

Trying to teach myself cross-validation on a super simple example, linear regression. My understanding is that when I build a model via CV, it should have a lower RMSE. But I find almost identical ...
user avatar
  • 450
0 votes
2 answers
48 views

What statistical test is suitable to summarise patient time in hospital with health condition

I am working on a dataset in which I am trying to summarise patient time in hospital by age and any health condition(e.g Cancer, Deprivatin, Depression or any). In my case it's Deprivatin. Patient ...
user avatar
0 votes
0 answers
16 views

about Feasible GLS and OLS in R

I have question about FGLS and OLS. If the FGLS coefficients are not much difference with OLS coefficients, which results are more robust in this case? coefficients of OLS model ...
user avatar
  • 1
0 votes
0 answers
21 views

What method to find relation between variable A and B with unequal replicates in different plot

I have an experimental setting as illustrated below. Two different set of soil variables (say A and B) were taken in multiple plots (Plot1, Plot2, Plot n, those are not properly plot maybe... rather ...
user avatar
  • 1
2 votes
1 answer
31 views

What is the effect size `h` in `pwr::pwr.p.test` in `R`?

The R package pwr has a function for calculating the required sample size for a one-sample proportion test (I assume a z-test ...
user avatar
  • 32.4k
0 votes
0 answers
16 views

Is Kolmogorov–Smirnov test appropriate for what I describe in this question's body?

I basically have a ranked list of genes (0-1) the higher the score the better. I then want to intersect an independent list of genes to that ranked list, and then I need to calculate a p-value that ...
user avatar
1 vote
1 answer
21 views

Glm with all explanatory variables included gives same probability for all coefficients. Why?

I have a dataset containing the proportion of different land use categories in a circular plot around presence and randomly placed absence points of little owls. The dataset looks like this: As you ...
user avatar
  • 23
0 votes
0 answers
22 views

Unexpected wide confidence intervals with lsmeans glm binomial

I have a dataset with 2 factors (sorte / meristemposition) and a binary response (0/1) and ran a glm model in R including the interactions: ...
user avatar
  • 101
0 votes
0 answers
11 views

Checking the results of the Metropolis - Hastings generated sample

I've generated a sample for the distribuition $f(x) \propto cos(x), x \in [-\frac{\pi}{2}, \frac{\pi}{2}]$ through the Metropolis - Hastings algorithm. For that I've used as candidate distribuition $q ...
user avatar
  • 77
-1 votes
0 answers
16 views

Can "Heavily Skewed" Predictor Variables be "Useful" to a Model?

In school, we were always told some general/informal "heuristics" about statistical modelling. In particular, we were advised about the following point: If most of the variable contains ...
user avatar
  • 5,892
0 votes
0 answers
9 views

Why does the negative binomial produce multiple threshold parameters in Stata but not in lme4?

Stata produces estimates for the thresholds of a negative binomial regression, as demonstrated here. However, the same does not happen with lme4 in ...
user avatar
0 votes
1 answer
32 views

"NA" in multiple regression

I have a question about multiple regression data$x4 <- with(data, x1+x2) #x4=x1+x2 y = b0 + b1x1 + b2x2 + b3x3 mod1 <- y ~ x1 + x2 + x3 + x4 I ran ...
user avatar
  • 1
0 votes
0 answers
16 views

nmle:gls with AR or MA terms

I am using nlme:gls to model trends. My understanding is that including AR or MA terms allows the model the correlation structure of the residuals rather than affecting the the regression estimates. ...
user avatar
1 vote
1 answer
51 views

Writing mathematical equations (mixed effect models)

I have the following model which i am trying to write the mathematical equation for. model; mod = lmer(test ~ IQ + ses + (1 | Class), data = pupils) I have the ...
user avatar
  • 49
1 vote
0 answers
16 views

What does it mean when a feature or variable has non-significant t test statistics but significant p values in F test (anova)?

I ran a linear regression model with 15 features in R. 5 of them are categorical features (converted to factors and first category dropped for each of them). 10 are continuous features (already scaled)...
user avatar
0 votes
0 answers
17 views

Accuracy measures for moving average

I have 12 weeks of sales data and I'm using a moving average to forecast the 13th week of sales. I know that I can do this using the SMA function from the TTR package, the sma function from the smooth ...
user avatar
3 votes
2 answers
78 views

Summarising and Visualising three attributes in R

I am trying to summarise and visualise three attributes in R: Patient_Age, Patient_Deprivation and Hospital_Time. I am trying to summarise the time patients spent in hospital by deprivation(scale 1-5) ...
user avatar
1 vote
0 answers
28 views

How to conduct a boostrapped or a permutation wilcoxon test (in R)

I have a total of 18 mice, 9 from Healthy group and 9 from Sick group. Since I have a very poor sample size I would like to use boostrapping or permutation test. Is there a way to conduct a ...
user avatar
  • 467
1 vote
0 answers
41 views

Best statistical test to compare outcomes of glm's?

For my thesis, I am comparing the differences in habitat selection of little owls between 2005 and 2022. For both years I have little over 100 presence points (value 1) with a buffer of 50 meters ...
user avatar
  • 23
3 votes
1 answer
56 views

Linear model with constraints in R

I have the following problem: I have a simple linear model with 3 independent variables. ...
user avatar

1
2 3 4 5
547