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
0 answers
22 views

Plotting Kernel Density Estimates on Same Axes in R

Here: https://www.python-graph-gallery.com/74-density-plot-of-several-variables Python's seaborn library is used to illustrate how to plot multiple kernel density ...
  • 1,339
1 vote
1 answer
32 views

What can cause violation of the proportional odds assumption?

What can the reasons be that the assumption of proportional odds / assumption of parallel regression lines is not met? By using MASS::polr in R, I tried to run ...
  • 53
0 votes
0 answers
10 views

Why do the results of Dunn's test in GraphPad Prism and R differ?

I have three sets of data, to which I want to apply Dunn's test. However, the test shows different results when performed in GraphPad Prism and R. I've been reading a little bit about the test here, ...
0 votes
0 answers
30 views

What about the tails of a ggplot line graph?

Here is my data with value (numeric), group (A/B), Time (T1,T3), and Condition (neutral/reward) variables. ...
0 votes
1 answer
38 views

Mixed effects logistic regression model

I have a dataset that looks somewhat similar to this: ...
  • 11
0 votes
1 answer
23 views

stratification or two-way interaction with multilevel categorical variable

I have a data with around 1600 patients from an observational study, around 230 events. 800 have a disease, and the rest do not. My main question is the effect of therapy in a multivariable adjusted ...
0 votes
0 answers
10 views

Why is my concordance measure greater than 1?

I've written a function to assess the coefficient of concordance for vague data. I'm using it to measure consistency in the rank order of some items ranked by two reviewers. It's vague because each ...
  • 93
1 vote
0 answers
10 views

Similiarity between two corpus of text

I have two separated corpus of text, and i would like to understand wheter these are similiar or not using cosine similarity. I'm not sure on how to approach this problem, but i was thinking as a ...
0 votes
0 answers
9 views

How to calculate VaR on DCC GARCH?

I am using a DCC (and CCC) GARCH model to model volatility of electricity price returns (using spot and futures) i.e. I have more variables in my model. I need to calculate VaR using these models but ...
1 vote
1 answer
32 views

How are the confidence intervals calculated in the hw() function the the forecast package in R?

I have been using the hw() function from the forecast package to predict some timeseries objects. I've noticed for some of my timeseries predictions, the prediction interval sizes are almost the exact ...
0 votes
0 answers
12 views

How to remove missing data for PCA

Im a biochem major, and im taking a population genetics class that we only need to know the tiniest bit of R for one project. (therefore we are using GenePop) I have a huge data set that when analyzed ...
  • 1
0 votes
0 answers
15 views

Applying a distribution to data over time in R

I have data on trains departing a train station every day over a month. The data includes the departure time and the number of passengers travelling. I have a separate dataset which estimates, in 5 ...
1 vote
0 answers
53 views

Detecting isolation/segregation in classroom data

Suppose we have two groups of students: A and B. We want to look at the distribution of these two groups of students in each ...
  • 916
0 votes
1 answer
50 views

Why does the output of logistic regression using GLM is different from using the formula 1/(1+exp(-y)) with y=b0 + b1*x1 + b2*x2 + ... + bn?*xn

When I use glm with family=binomial I get different results than if I use the direct formula, I have looked for an explanation for this and I can't find anything. I hope you can help me! ...
user avatar
0 votes
0 answers
8 views

How do you use FIML with a Mixed Measures Anova in R?

I am conducting a Mixed Measures Two-Way ANOVA in R to test the effect of an intervention. There are two conditions (control and intervention) with two time-points (pre-test and post-test). Each ...
  • 1
3 votes
1 answer
76 views

Assessing homogeneity of variances assumption for numeric variables

I'm fitting a model with a 2-level categorical and a numerical predictor. As far as I'm concerned, I cannot use car::LeveneTest() to assess homoscedasticity since I ...
0 votes
0 answers
14 views

Topic models: estimating parameters of a model with a single covariate and fixed topic prevalence

Is there a way to estimate the parameters influencing word probabilities in a Structural-Topic-Model type of model with a single nominal covariate, given that the topic prevalence in documents is ...
  • 395
0 votes
0 answers
14 views

Pre and post intervention (same subjects) with different outcome (successful and unsuccesful) as a result of the treatment

i have pre and post measurements of biodata (20 clinical measurements) taken before and after the treatment from a group of 30 people, out of which I have 20 successful and 10 unsuccessful subjects. I ...
1 vote
2 answers
43 views

Visualizing matrix with high numerosity?

I have a matrix with many rows (>18000) and few columns (6), where five are numerical and one is a binary factor and i'd like to find an efficient and simple way to visualize the relationship ...
0 votes
0 answers
14 views

Fractional design with blocking in R?

Is there a package in R to create an experiment design with fractional design which provides blocking a specific factor? In addition, more than two levels should be possible.
  • 2,649
0 votes
0 answers
5 views

transformation of binary vectors

I need to solve the next idea. I have a dataset with many individuals with information about an intervention every individual appears 4,5,6 or 7 times in the data set. I need to specify that If the ...
  • 945
3 votes
1 answer
122 views

How to find the strongest correlation with big data in R? [closed]

I am trying to find the strongest correlation between two data sets in R and one set has 9000+ columns. I used cor() and it worked well, but is there a function or way to find the strongest ...
0 votes
0 answers
21 views

Baseline-adjusted ANCOVA vs baseline-adjusted LME

I'm a bit of a novice at this so please be nice! Essentially, I want to know which method is the most statistically sound in application. I have two groups (allocation), two time points (pre/post), a ...
1 vote
0 answers
53 views

Marginal effects for interaction terms

I am trying to compute probit regression that includes interaction terms. When I compute marginal effects after the main coefficients R gives me marginal effects for interaction terms and Stata doesn'...
user avatar
1 vote
1 answer
24 views

fit gamma distribution based on median interquartile range

I would like to create a gamma probability distribution in R with a median of 3 and interquartile range of [2,5]. I am familiar with the methods of moments to estimate the scale and shape of a gamma ...
  • 35
0 votes
1 answer
31 views

Why is there an apparently large difference between Bartlett and Levene's test in this problem?

When running tests for homoscedasticity, using R gave the following results: ...
  • 11
0 votes
0 answers
12 views

Independent 2SLS not matching up with plm package in R?

I am attempting to run a two stage least squares IV regression, where I have one endogenous variable (x1) and four instruments (z1, z2, z3, z4). I have panel data and am thus attempting to control for ...
  • 1
0 votes
1 answer
33 views

Compute value at risk from DCC GARCH (in R)

I am struggling to obtain the Value at Risk from my DCC GARCH analysis. I have done the following code: ...
0 votes
1 answer
10 views

SVAR in R - Bmat matrix needs have same # of rows as Amat

I'm running an SVAR in R, following this guide: https://levelup.gitconnected.com/structural-vector-autoregression-in-r-5d6dbfc56499, with slightly different variables (CPI -> Violent Crime Rates -&...
0 votes
1 answer
23 views

Mixture of Two Normals

Suppose we have a data which consists of two normals, x = rnorm(50,mean=1,sd=2) y = rnorm(50,mean=2,sd=3) z = sample( c(x,y) , size = 100, replace=FALSE ) The goal ...
0 votes
1 answer
37 views

Logistic regression via robust glm (glmrob) not appropriate if have only one observation in one of two categories of an independent variable?

I received abnormal results when using glmrob (R function from robustbase) when assessing the association of a binomial independent variable X0 with a binomial dependent variable Y using logistic ...
  • 76
1 vote
0 answers
51 views

Identify groups/associations among longitudinal binary variables

This question is an extension of a prior question. I have a longitudinal dataset with several binary variables, along with an id variable and a ...
0 votes
0 answers
24 views

Improving and interpreting linear model in R

I have the following code in R: ...
1 vote
1 answer
22 views

likelihood value calculation with glm

I have 2 questions regarding the likelihood value calculation with glm. It seems that sometimes it calculates the likelihood value including the binomial coefficient and sometimes it does not. Tow ...
1 vote
1 answer
31 views

R ordered logit regression polr

I have result from R: polars ...
user avatar
1 vote
0 answers
85 views

Residuals not normal due to random effects structure

I am new to mixed-effect models and statistics, and I need to do a project for my thesis using mixed-effect modeling techniques. My research aims to model how cardiovascular risk scores change over ...
2 votes
1 answer
45 views

How to calculate F-statistic given only coefficient, standard errors and confidence intervals in R [closed]

My output is a table of coefficients, together with standard errors and 90 % confidence intervals, nothing else. I miss the degrees of freedom but I do have the number of observations. How can I ...
  • 151
0 votes
1 answer
15 views

R nlme mixed model-how to run model by study subject

I'm trying to run a simple mixed model by subject id: y=week. Since it's repeated measures, I assume that I need to use mixed model even though I want to run the model by subject id? In addition, ...
  • 1
0 votes
0 answers
9 views

Cross correlation analysis on Bray-Curtis dissimilarity matrix with environmental variables

I'd like to use a cross correlation analysis to examine whether there are temporal lags between environmental factors and changes in ecological community structure, but I am not sure how to structure ...
1 vote
1 answer
38 views

R plm fixed effect model where the index and fixed effects variables are not the same

I used the plm() function for a 2-way fixed effect model with zip_code and month (yy-mm) ...
0 votes
0 answers
18 views

How to use optFederov() and others for DoE?

As a follow up on DOE for evaluating a factor with more than 2 levels I would like to address some questions: How do I determine the number of trials (in general and for a fractional design)? Which ...
  • 2,649
3 votes
3 answers
275 views

Multivariable Logistic in R, without the "reference" level in a categorical predictor

I am dealing with the following problem: I have to do a multivariable logistic in R, using the command glm with the argument ...
  • 31
0 votes
0 answers
15 views

How to reduce concurvity with space-time smooth in GAM?

In these notes, Simon Wood gives an example on how to tackle high concurvity when a spatial term is present in a GAM. With spatial confounding it sometimes helps to increase the smoothing parameter ...
  • 15
0 votes
1 answer
38 views

How to find the expected value and median of a chi square distribution with $12$ dof in R?

How can I find the expected value and median of $X\sim \chi^2$ with degrees of freedom of $12\,$? The information I get from every other source, I find, is confusing. I am using R.
  • 9
0 votes
0 answers
33 views

When can the lower bound of a confidence interval be used?

I'm performing analysis on the data found in the NHANES package in R. One of the vectors describes the estimated number of days that participants drank alcoholic beverages. I want to classify them as ...
  • 43
0 votes
0 answers
20 views

I am attempting to find the Adjusted Odds Ratio using a multivariable logistic regression in R

I am working on a multivariable logistic regression model in R. My goal is to compare Mortality for a female cohort group using males as a reference. I have specified males to be 0 and females to be 1....
0 votes
1 answer
41 views

Improving linear regression by transforming predictors

I'm working on the insurance dataset with R, and I'm trying to do a lm with charges as the target. I did the following: Removed ...
0 votes
1 answer
18 views

A function to conduct post hoc chisquare goodness of fit test in R?

I have this vector of frequency values x = c(100,400,500,600,700) when conducting chi square test goodness of fit I have this result that has a global ...
  • 221
0 votes
1 answer
51 views

Stata's margins and R's marginal effects' comparisons

I was looking for an equivalent for Stata's command lincom in R. I tried the comparisons() function from marginaleffects package. However, I get different ...
0 votes
1 answer
16 views

Iterating over set of functions in logistic regression

I am trying to find the best fitting function in case of logistic regression using R. ...