Displaying 20 results from an estimated 4272 matches for "x2".
Did you mean:
0x2
2007 Mar 10
3
long character string problem
...ct'. How can I remove these double-quotes? I
tried as.name() but it did not work (because of size?). These are creating
trouble with subsequent programs, which I tested with strings that for some
reason do not have these double quotes (see very bottom).
> cum1
[1]
"A11*(X11*x1+X21*x2)+1*sqrt(B11*(X11*x1+X21*x2)^2+C11)A12*(X12*x1+X22*x2)+1*sqrt(B12*(X12*x1+X22*x2)^2+C12)A13*(X13*x1+X23*x2)+-1*sqrt(B13*(X13*x1+X23*x2)^2+C13)A14*(X14*x1+X24*x2)+-1*sqrt(B14*(X14*x1+X24*x2)^2+C14)A15*(X15*x1+X25*x2)+1*sqrt(B15*(X15*x1+X25*x2)^2+C15)A16*(X16*x1+X26*x2)+1*sqrt(B16*(X16*x1+X26*x2)^...
2006 Jul 08
2
String mathematical function to R-function
hello
I make a subroutine that give-me a (mathematical)
function in string format.
I would like transform this string into function ( R
function ).
thanks for any tips.
cleber
#e.g.
fun_String = "-100*x1 + 0*x2 + 100*x3"
fun <- function(x1,x2,x3){
return(
############
evaluation( fun_String )
############
)
True String mathematical function :-( :-(
> nomes
[1] "8.49*x1*z1 + 6.13*x1*z2 + 6.4*x1*z3 + 6.9*x2*z1 +
4.54*x2*z2 + 3.99*x2*z3 + 19.31*x3*z1 + 12.49*x3*z2 +
3.86*x3*z3 + 5.2...
2009 Jun 08
5
if else
Hi R-helpers!
I have the following dataframe:
firm<-c(rep(1:3,4))
year<-c(rep(2001:2003,4))
X1<-rep(c(10,NA),6)
X2<-rep(c(5,NA,2),4)
data<-data.frame(firm, year,X1,X2)
data
So I want to obtain the same dataframe with a variable X3
that is:
X1, if X2=NA
X2, if X1=NA
X1+X2 if X1 and X2 are not NA
So my final data is
X3<-c(15,NA,12,5,10,2,15,NA,12,5,10,2)
finaldata<-data.frame(firm, year,X1,X2,X3)...
2017 Oct 12
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...tegorical
variables when the full hierarchy of effects is not present. Depending on
which lower level interactions are specified, the factor encoding changes
for a higher level interaction. Consider the following minimal reproducible
example:
--------------
> runmatrix = expand.grid(X1=c(1,-1),X2=c(1,-1),X3=c("A","B","C"))> model.matrix(~(X1+X2+X3)^3,data=runmatrix) (Intercept) X1 X2 X3B X3C X1:X2 X1:X3B X1:X3C X2:X3B X2:X3C X1:X2:X3B X1:X2:X3C
1 1 1 1 0 0 1 0 0 0 0
0 0
2 1 -1 1 0 0 -1...
2007 Apr 16
2
Simplify simple code
Dear expeRts,
I would simplify following code.
---------------------------------------------
youtput <- function(x1, x2){
n <- length(x1)
y <- vector(mode="numeric", length=n)
for(i in 1:n){
if(x1[i] >=5 & x1[i] <= 10 & x2[i] >=5 & x2[i] <=10)
y[i] <- 0.631 * x1[i]^0.55 * x2[i]^0.65
if(x1[i] >=10 & x1[i] <= 15 & x2[i] >=5 & x2[...
2009 Mar 09
2
path analysis (misspecification?)
hi,
I have following data and code;
cov <-
c
(1.670028
,-1.197685
,-2.931445,-1.197685,1.765646,3.883839,-2.931445,3.883839,12.050816)
cov.matrix <- matrix(cov, 3, 3, dimnames=list(c("y1","x1","x2"),
c("y1","x1","x2")))
path.model <- specify.model()
x1 -> y1, x1-y1
x2 <-> x1, x2-x1
x2 <-> x2, x2-x2
x1 <-> x1, x1-x1
y1 <-> y1, y1-y1
x2 -> y1, x2-y1
summary(sem(path.model, cov.matrix, N = 422))
a...
2014 Sep 10
4
[RFC PATCH v1 0/3] Introducing ARM SIMD Support
libvorbis does not currently have any simd/vectorization.
Following patches add generic framework for simd/vectorization
and on top, add ARM-NEON simd vectorization using intrinsics.
I was able to get over 34% performance improvement on my
Beaglebone Black which is single Cortex-A8 based CPU.
You can find more information on metrics and procedure I used
to measure at
2010 Aug 03
2
Collinearity in Moderated Multiple Regression
Dear all,
I have one dependent variable y and two independent variables x1 and x2
which I would like to use to explain y. x1 and x2 are design factors in an
experiment and are not correlated with each other. For example assume that:
x1 <- rbind(1,1,1,2,2,2,3,3,3)
x2 <- rbind(1,2,3,1,2,3,1,2,3)
cor(x1,x2)
The problem is that I do not only want to analyze the effect of x1...
2012 Feb 18
1
proto: make a parameter persist
The code below works as expected but:
Using the proto package, is this the best way to 1) make a parameter
persist if the parameter is passed
in with a value, 2) allow for calling the bias() function without a
parameter assignment, 3) have
the x2 value initialize as 5? Thanks for your feedback. Giving the
proto package a test beat and
establishing some templates for myself.
> oo <- proto(expr = {x = c(10, 20, 15, 19, 17) x2 = 5 # so x2 initializes as 5, but can be overwritten with param assignment...
2008 Mar 29
1
Tabulating Sparse Contingency Table
I have a sparse contingency table (most cells are 0):
> xtabs(~.,data[,idx:(idx+4)])
, , x3 = 1, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 31
2 0 0 112
3 0 0 94
, , x3 = 2, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 3, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 1, x4 = 2, x5 = 1
x2
x1...
2017 Nov 06
2
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
Hello Tyler,
You write that you understand what I am saying. However, I am now at
loss about what exactly is the problem with the behavior of R. Here
is a script which reproduces your experiments with three variables
(excluding the full model):
m=expand.grid(X1=c(1,-1),X2=c(1,-1),X3=c("A","B","C"))
model.matrix(~(X1+X2+X3)^3-X1:X3,data=m)
model.matrix(~(X1+X2+X3)^3-X2:X3,data=m)
model.matrix(~(X1+X2+X3)^3-X1:X2,data=m)
Below are the three results, similar to your first mail. (The first
two are basically the same, of course.) Please pic...
2017 Oct 15
0
Bug in model.matrix.default for higher-order interaction encoding when specific model terms are missing
...ing variable. More
precisely: for all values of that variable. In other words: you have a
three-way interaction, with all values of that variable.
An even smaller example is the following script with only two
variables, each being a factor:
df <- expand.grid(X1=c("p","q"), X2=c("A","B","C"))
print(model.matrix(~(X1+X2)^2 ,data=df))
print(model.matrix(~(X1+X2)^2 -X1,data=df))
print(model.matrix(~(X1+X2)^2 -X2,data=df))
The result is:
(Intercept) X1q X2B X2C X1q:X2B X1q:X2C
1 1 0 0 0 0 0
2 1 1...
2020 May 23
1
base::order breaking change in R-devel
...results on R 4.0.0 and R-devel
(2020-05-22 r78545). I haven't found any info about that change in
NEWS. Was the change intentional?
Sys.setlocale("LC_CTYPE","C")
Sys.setlocale("LC_COLLATE","C")
x1 = "fa\xE7ile"
Encoding(x1) = "latin1"
x2 = iconv(x1, "latin1", "UTF-8")
base::order(c(x2,x1,x1,x2))
Encoding(x2) = "unknown"
base::order(c(x2,x1,x1,x2))
# R 4.0.0
base::order(c(x2,x1,x1,x2))
#[1] 1 4 2 3
Encoding(x2) = "unknown"
base::order(c(x2,x1,x1,x2))
#[1] 2 3 1 4
# R-devel
base::order(c(x2,x...
2004 Jul 16
3
still problems with predict!
Hi all,
I still have problems with the predict function by setting up the values on
which I want to predict
ie:
original df: p1 (193 obs) variates y x1 x2
rm(list=ls())
x1<-rnorm(193)
x2<-runif(193,-5,5)
y<-rnorm(193)+x1+x2
p1<-as.data.frame(cbind(y,x1,x2))
p1
y x1 x2
1 -0.6056448 -0.1113607 -0.5859728
2 -4.2841793 -1.0432688 -3.3116807
......
192 -1.3228239 1.0263013 -2.7801324
193 1.8736683 1.0480632...
2007 Nov 30
2
List operations in R
hello:
I am very confused when it comes to list operations in
R.
I seek help in the following problem.
I have two different vectors
myIDs - a character vector with no names to their
elements
x2 - another character vector derived from unlisting a
list where an element has both a name and value.
I am not happy the way x2 is with names and values to
every element.
> myIDs[1:10]
[1] "54898" "7083" "7031" "7083" "4175" "4605&q...
2011 Sep 10
0
npreg: plotting out of sample, extremely large bandwidths
Hello r-help,
I am using the excellent np package to conduct a nonparametric kernel
regression and am having some trouble plotting the results.
I have 2 covariates, x1 and x2, and a continuous outcome variable y. I
am conducting a nonparametric regression of y on x1 and x2. The one
somewhat unusual feature of these data is that, to be included in the
dataset, x1 must be at least as large as x2.
The basics of the analysis are to calculate the correct bandwidth
using npr...
2014 Nov 15
2
[LLVMdev] Upcoming Changes/Additions to Scoped-NoAlias metadata
...quot;Chandler Carruth" <chandlerc at google.com>, "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Sent: Friday, November 14, 2014 5:31:24 PM
> Subject: Re: [LLVMdev] Upcoming Changes/Additions to Scoped-NoAlias metadata
>
> You don't have x1 and x2 in your example, assuming you mean:
>
> int i = 0;
> T A;
> T * y2 = ...
> {
> T * x1 = &A;
> a = x1[i];
> }
> {
> T * restrict x2 = y2;
> b = x2[i];
> }
>
> then the answer is no, the fact that x2 is restrict qualified does
> not allow us to concl...
2010 Jan 08
4
Arguments of a function
Dear all,
I have a question about how to set arguments in my own function. For
example, I have a function that looks like this:
my.f <- function(a = x1, b = x2)
{
x1 = equation 1
x2 = equation 2
x3 = equation 3
y = a + b
}
x1, x2, and x3 are temporary variables (intermediate results) calculated
from other variables within the funciton. I want to use two of these three
variables to calculate y, and write R script as below:
my.f(a = x1, b =...
2015 Jan 22
5
Simulación de modelo logit con interacción
...obtengo que los coeficientes estimados no se asemejan mucho a los originales. ¿Se le ocurre a alguien cuál es el motivo de esta discrepancia? ¿y cómo solucionarlo?
Muchas gracias
Emilio
logisticsimulation <- function(n){
dat <- data.frame(x1=sample(0:1, n,replace=TRUE),
x2=sample(0:1, n,replace=TRUE))
odds <- exp(-1 - 4 * dat$x1 + 7*dat$x2 - 1 *dat$x1* dat$x2 )
pr <- odds/(1+odds)
res <- replicate(100, {
dat$y <- rbinom(n,1,pr)
coef(glm(y ~ x1*x2, data = dat, family = binomial()))
})
t(res)
}
res <- logisticsimulation(100)
apply(res,...
2012 Apr 20
1
predictOMatic for regression. Please try and advise me
...t;- cbind(mixAndMatch, modelcv[ ,!colnames(modelcv) %in%
colnames(mixAndMatch)])
newdf
}
predictOMatic <- function(model = NULL, fl = NULL, ...){
nd <- newdataMaker(model, fl)
fit <- predict(model, newdata=nd, ...)
cbind(fit, nd)
}
set.seed(12345)
x1 <- rnorm(100)
x2 <- rnorm(100)
x3 <- rnorm(100)
x4 <- rnorm(100)
x5 <- rpois(100, 5)
x6 <- rgamma(100, 2,1)
xcat1 <- gl(2,50, labels=c("M","F"))
xcat2 <- cut(rnorm(100), breaks=c(-Inf, 0, 0.4, 0.9, 1, Inf),
labels=c("R", "M", "D", "P",...