# 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.

19,742 questions
29 views

### How to correctly model repeated-measures random effects in a linear mixed effects model

I have a mixed design data set where participants respond to each of three interventions and also report various demographics. The intervention is thus repeated-measures and each demographic measure ...
7 views

### Initial simplex for the Nelder-Mead algorithm in R using the “optim” function

How does R create the initial simplex when using the "optim" function? Is it different to the method applied in Matlab's "fminsearch"? Are there any other differences in the implementation? I have ...
15 views

### Jaccard Index for Binary Data in R using dist function

I have a presence/absence table of 0s and 1s and I would like to cluster this data. I want to create a pairwise matrix using R's dist function which has a binary ...
24 views

### How to calculate coverage probability in R for cauchy distribution?

I know that the coverage probability is $P(|\hat{\theta}-\theta|\leq\epsilon)$. My task is to compare estimators of the Cauchy distribution for the location $\theta$. I've plotted the estimators and ...
19 views

### How are these two power law fitting glm models different?

I have some data that I thought I'd try fitting with a power law (in R). ...
10 views

### Effect size on the difference between group differences (ΔA-B vs ΔA-C) using R

I am trying to calculate effect sizes, but all I can find on the web relates only to the effect size of the difference between two groups. What I am interested in, is the effect size of the difference ...
35 views

### How do I set up the data for a Friedman Test?

Below is a small sample of a very large data set (over 10,000 records). All I'm trying to do is determine if there's a statistically significant difference found in the ordering of supplies among ...
11 views

### problems in plotting decimal value distribution with bin width normalization in r using hist()

I am plotting data distribuiton. I get the expected plot with data which are only integer numbers. But I didn't get appropriate plot for decimal data sets. The code with integer numbers data as ...
21 views

30 views

### R - Help interpreting GLM and ANOVA output

Am I correct in understanding that the effects of flood.level and plant.species are significant predictors of Inv.Simpson (my measure of diversity)? Is it also correct to say that the effect of ...
17 views

### Predicting whether a potential business agreements will be won or lost [on hold]

I am currently working on a project using a sales system and trying to come up with a way to use the current pipeline of potential sales to predict if the business agreements will win or lost based on ...
63 views

### Model for forecasting daily page views of a web page in R

I have to forecast daily page views of a web portal. We have the daily page views of the data for the last 2 years. We have to forecast for next 90 days. I am using a multi-seasonal (with season ...
5 views

### Assign variable name to desired parts in a function in R [closed]

I am new to R and here. Sorry If I am complicated. I created a function by trial name. There are some functions from my own function below. ...
7 views

### Is there a R package of text mining which does string matching using “CTE+CDAM” http://www.vldb.org/pvldb/vol7/p1167-londhe.pdf? [closed]

I try to use string matching algorithm to calculate string distance, i.e, how similar two strings are. I am using two R packages: tm and stringdist. But I found there is a paper "matching titles with ...
51 views

### How to choose “family” in Generalized Additive Model (GAM)

When modelling a GAM model using mgcv in R, we need to define the family = . I tried some families (e.g., Gaussian, Gamma), R ...
12 views

### R Replicate observations in Dataframe [closed]

I have 3 factors, the first one is call cat1, range from 'a' to 'd', and the second factor, cat2, has two levels, 'Y'/'N', and the 3rd, cat3, have 3 levels, 0/1/2, i would like to generate below data ...
13 views

### glmer model failed to converge but converge_ok says TRUE yet is.singular says FALSE; can I trust my model summary?

I'm comparing a series of models using glmer in lme4: ...
27 views

### How to add covariate x time interaction term in poisson model in R(relsurv package)

I tried to do relative survival analysis specifically poisson regression in relsurv package. And I want to include covariate x time interaction term since the hazard (or excess hazard) in my model is ...
16 views

### How to make a loop skip the space between words in R [closed]

i need to write caesar cipher function, and it doesnt work on strings with space. ...
124 views

### Time series forecast - ARIMA/ARIMAX with daily data [on hold]

I am working on a project to analyse and forecast time series for sales and revenue of a client. There are various models that i want to test for accuracy purposes - namely Holt Linear Method, Holt ...
15 views

### Including all rows for an ID if ID meets a condition once in panel data in R [migrated]

I'm sorry if a similar question has been answered already but I can't seem to find any posts helping me. I wish to define two separate intervention groups (linked to this previous question I asked ...
17 views

### I need to do the Caesar chipher code. it doesnt work well [closed]

my code works only on numbers between 1-26 and only on string of one word. ...
10 views

### I want to do a vector of string [closed]

How can I do that space between words will not be count? For example: ...
17 views

### Mixed effect zero inflated negative binomial model: “the leading minor of order 1 is not positive definite”

I am having trouble fitting a mixed effect zero inflated negative binomial model to my data using the GLMMadaptive package: ...
17 views

### static random effect probit model [closed]

I am novice in R language and need help I need help in R language to code static random effect probit model. Requirement for model is Y and X are observable and fixed effect & beta are to be ...
14 views

### Likelihood ratio test function- manually in R [closed]

I am trying to write a function in R, which implements the likelihood ratio test for all well known densities. The input must contain datas, the density function, and the H0 parameter, with its name. ...
28 views

### problem regarding time series modeling using R

I have this time series data and my aim is to fit a time series model. When i plot the time series data , it seems to be data is not stationary. These are the plots based on the first difference, ...
15 views

### What does linear regressor output mean? I am using tensorflow estimator in R

I try the code at tensorflow in R tutorial (https://tensorflow.rstudio.com/tfestimators/) but I cannot understand the output what the code produces. Code: ...
15 views

### Weighting of the mean [closed]

I have this kind of data: z x y 1 A 50 2 B 10 3 B 30 4 C 20 5 C 30 6 C 5 x is a provider of a product and ...
27 views

### Splitting panel data into subgroups

I have a (an unbalanced) panel dataset of individuals over different periods of time (one time period = one month). I'm attempting to analyse the effect on the level of activity of the individuals of ...
19 views

### R: Methodologically sound way to determine which interaction effects to include in logistic regression? glmulti()?

I ran a logistic regression (in R using the glm function) and didn't find significance for a variable I expected to be significant (numerous articles have found significance). When I examined my data ...
25 views

### Optimisation by using directional derivative

So I’ve seen the code of an R package where a two dimensional optimisation (actually MLE, finding the minimum of the negative log likelihood) is performed with the optim function and also two optimise ...
46 views

### Error message: Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric [closed]

I'm new to R, and have been trying to run PCA on all the variables. I've included a screenshot of my ...
35 views

### Understanding the example in ?prcomp (R)

I'm trying to understand, in simple terms, the following example copied from prcomp in R: ...
76 views

### Ripley K function value in a specific radius and dataset using R's Kest function

I'm having general trouble with calculating Ripley's K function values. The following is a simple spatial point pattern, where both X and Y range from 0 to 200: Here's its corresponding Ripley K ...
50 views

### My P-value Manually Calculated is Different from when I use the Prop-Test, in R Studio

Trying to calculate the p-value manually and then demonstrate it using the Prop test but I keep getting different P-values. ...