similar to: Specifying arguements in user defined functions

Displaying 20 results from an estimated 9000 matches similar to: "Specifying arguements in user defined functions"

2003 Nov 07
2
Annoteting graphs using text
Dear All, I am new to R and am trying to learn how to create functions using R. Below is code which calculates Lin's Concordance Coefficient. After I calculate the coefficient I want to create a scatter plot which annotates the coefficient along with preceding text onto the plot. The below code doesn't seem to work. If I use only the object 'lincc' on the text command it works
2004 Oct 22
1
cor, cov, method "pairwise.complete.obs"
Hi UseRs, I don't want to die beeing idiot... I dont understand the different results between: cor() and cov2cov(cov()). See this little example: > x=matrix(c(0.5,0.2,0.3,0.1,0.4,NA,0.7,0.2,0.6,0.1,0.4,0.9),ncol=3) > cov2cor(cov(x,use="pairwise.complete.obs")) [,1] [,2] [,3] [1,] 1.0000000 0.4653400 -0.1159542 [2,] 0.4653400 1.0000000
2008 Jan 02
2
strange behavior of cor() with pairwise.complete.obs
Hi all, I'm not quite sure if this is a feature or a bug or if I just fail to understand the documentation: If I use cor() with pairwise.complete.obs and method=pearson, the result is a scalar: ->cor(c(1,2,3),c(3,4,6),use="pairwise.complete.obs",method="pearson") [1] 0.9819805 The documentation says that " '"pairwise.complete.obs"' only
2004 Nov 05
1
covariance bug (PR#7342)
Full_Name: Christian Lederer Version: 1.8.0 OS: Linux Submission from: (NULL) (217.229.7.13) R-1.8.0 seems to calculate wrong covariances, when the argument of cov() is a matrix or a data frame. The following should produce a matrix of zeroes and NaNs: x <- matrix(c(NA ,NA ,0.9068995 ,NA ,-0.3116229, -0.06011117 ,0.7310134 ,NA ,1.738362 ,0.6276125, 0.6615581 ,NA
2011 Jan 31
2
computing var-covar matrix with much missing data
Is there an R function for computing a variance-covariance matrix that guarantees that it will have no negative eigenvalues? In my case, there is a *lot* of missing data, especially for a subset of variables. I think my tactic will be to compute cor(x, use="pairwise.complete.obs") and then pre- and post-multiply by a diagonal matrix of standard deviations that were computed based
2007 Jun 18
1
the way to look at all the codings of any functions
Dear SIr, In case of looking at the codes of the fuction, "cov", we find all the codings below. But, incase of "mean", we don't find the contents. Please show me the way to look at all the codings of any functions. Best regards, Kei ----------------------- > cov function (x, y = NULL, use = "all.obs", method = c("pearson",
2009 Jun 02
2
variance does not equal serial covariance of lag zero?
Dear all, Does this make any sense: var() = cov() != acf(lag.max=0, type="covariance")? I have daily data of IBM for May 2005, and I'm using the logarithmic return: > ibm200505$LRAdj.Close [1] NA 0.0203152 0.0005508 -0.0148397 -0.0025182 0.0092025 -0.0013889 [8] 0.0098196 -0.0103757 -0.0274917 0.0005716 -0.0159842 -0.0074306 0.0091710 [15] 0.0002898 0.0226306
2008 Jun 26
2
constructing arbitrary (positive definite) covariance matrix
Dear list, I am trying to use the 'mvrnorm' function from the MASS package for simulating multivariate Gaussian data with given covariance matrix. The diagonal elements of my covariance matrix should be the same, i.e., all variables have the same marginal variance. Also all correlations between all pair of variables should be identical, but could be any value in [-1,1]. The problem I am
2008 Dec 15
2
Using a covariance matrix as input to relaimpo package
I'm having trouble getting the relaimpo package to use a covariance matrix as input. I'm getting an error message that reads as follows: Error in eval(m$weights, data, parent.frame()) : numeric 'envir' arg not of length one I'm guessing there is something wrong with the structure of my covariance matrix, but it looks fine to me. Pardon my R ignorance if this is an easy
2010 Jun 09
1
bug? in stats::cor for use=complete.obs with NAs
Arrrrr, I think I've found a bug in the behavior of the stats::cor function when NAs are present, but in case I'm missing something, could you look over this example and let me know what you think: > a = c(1,3,NA,1,2) > b = c(1,2,1,1,4) > cor(a,b,method="spearman", use="complete.obs") [1] 0.8164966 > cor(a,b,method="spearman",
2004 Sep 13
1
pairwise deletion of missing cases in lm
Does anybody know if there is some sort of "pairwise" option for handling missing cases in lm and computing the relevant statistics? I would be much obliged if anyone could help... Regards Alan Simpson Roberts Research Group
2000 Jan 31
1
Feature requests for princomp(.) : Allow cor() specifications
(all in subject). If I want to do a PC analysis in a situation with missing data, I may want to have same flexibility as with "cor(.)", e.g., I may want princomp(x, ..., use.obs = "pairwise.complete") Actually, I may want even more flexibility. Currently, princomp(.) has if (cor) cv <- get("cor", envir = .GlobalEnv)(z) else cv <-
2007 Oct 25
2
Novice programing question
Hi all, I apologize for the ignorance implicit in this question, but I'm having a hard time figuring out how R functions work. For example, if I wanted to write a function to compute a variance, I would do something like >my.var <- function(x) (sum(((x-mean(x)))^2))/(length(((x-mean(x))) ^2)-1) And this seems to work, e.g., > my.var(V1) [1] 116.1 > var(V1) [1] 116.1
2013 Mar 20
2
Dealing with missing values in princomp (package "psych")
Hello! I am running principle components analysis using princomp function in pacakge psych. mypc <- princomp(mydataforpc, cor=TRUE) Question: I'd like to use pairwise deletion of missing cases when correlations are calculated. I.e., I'd like to have a correlation between any 2 variables to be based on all cases that have valid values on both variables. What should my na.action be in
2013 Jan 23
2
CFA with lavaan or with SEM
Hi Sorry for the rather long message. I am trying to use the cfa command in the lavaan package to run a CFA however I am unsure over a couple of issues. I have @25 dichotomous variables, 300 observations and an EFA on a training dataset suggests a 3 factor model. After defining the model I use the command fit.dat <- cfa(model.1, data=my.dat, std.lv = T, estimator="WLSMV",
2024 Oct 04
1
apply
It's still hard to figure out what you want. If you have two vectors you can compute their (2x2) covariance matrix using cov(cbind(x,y)). If you want to compute all pairwise squared differences between elements of x and y you could use outer(x, y, "-")^2. Can you explain a little bit more about (1) the context for your question and (2) why you want/need to use apply() ? On
2006 Jul 25
1
PCA with not non-negative definite covariance
Am I correct to understand from the previous discussions on this topic (a few years back) that if I have a matrix with missing values my PCA options seem dismal if: (1) I don’t want to impute the missing values. (2) I don’t want to completely remove cases with missing values. (3) I do cov() with use=”pairwise.complete.obs”, as this produces negative eigenvalues (which it has in
2011 Apr 18
1
Multiple Groups CFA in Lavaan
Hello, I am trying to do a multiple groups CFA in lavaan and I get the following error message: Error in cov(data.obs, use = "pairwise") : 'x' is empty I'm not sure what this message is referring to, can anyone help me? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Multiple-Groups-CFA-in-Lavaan-tp3457971p3457971.html Sent from the R help mailing
2005 Oct 18
1
Defining range of x and y axis in pairs()
Hi, I have a problem to define the range of x and y axis in pairs() for my scatterplots. In low-level plots I can specify that by providing xlim and ylim. This also works for pairs() even if warnings tell me that it doesn't (see below). But if I add upper.panel and/or lower.panel it doesn't work - I get an error message saying that there's an error in "upper.panel
2008 Feb 27
4
Error in cor.default(x1, x2) : missing observations in cov/cor
Hello, I'm trying to do cor(x1,x2) and I get the following error: Error in cor.default(x1, x2) : missing observations in cov/cor A few things: 1. I've used cor() many times and have never encountered this error. 2. length(x1) = length(x2) 3. is.numeric(x1) = is.numeric(x2) = TRUE 4. which(is.na(x1)) = which(is.na(x2)) = integer(0) {the same goes for is.nan()} 5. I also try