covariance

How to do ANCOVA in R?

試著忘記壹切 提交于 2019-12-02 08:09:07
问题 I have a dataframe with three columns: data$input, data$output and data$category. Both input and output are continuous numerics, and categories are discrete characters. I know ANCOVA is a method that analyzes the effect of input on output while controlling for the effect of category. However I could not find the exact command to do for this online. Here is a small example of how the data would look like: input output category 1 0.4 0.55 A 2 0.5 0.66 A 3 0.6 0.57 A 4 0.3 0.23 B 5 0.4 0.53 B 6

How to do ANCOVA in R?

可紊 提交于 2019-12-02 05:26:13
I have a dataframe with three columns: data$input, data$output and data$category. Both input and output are continuous numerics, and categories are discrete characters. I know ANCOVA is a method that analyzes the effect of input on output while controlling for the effect of category. However I could not find the exact command to do for this online. Here is a small example of how the data would look like: input output category 1 0.4 0.55 A 2 0.5 0.66 A 3 0.6 0.57 A 4 0.3 0.23 B 5 0.4 0.53 B 6 0.7 0.75 B 7 1.1 1.31 C 8 0.9 1.01 C 9 0.8 0.58 C 10 0.5 0.34 C What commands should I input to perform

Covariance with C#

前提是你 提交于 2019-12-02 05:10:41
问题 I met some interesting covariance problem in my c# code. I have a generic Matrix<T> class, and it's been instantiated for example Matrix<int> , Matrix<object> and Matrix<Apple> . For my business logic, I've wrapped them into a generic Wrapper<T> . This Wrapper implements non-generic INonGenericWrapper interface. So, I have Wrapper<int> , Wrapper<object> and Wrapper<Apple> . My problem is: I would like to define a container for all those 3 Wrapper s. I can't say List<Wrapper<object>> , because

Why do I need an Interface for Covariance (out Type)?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 02:24:38
I just need to use the covariant out generic type modifier again. I had a class with a generic type and wanted to add an out but VS told me that this is only possible on interfaces. But why can I use the out modifier only on an interface? I helped myself in creating an interface copy of my class but this seems a little bit strange to me to only have an interface so I can use this modifier. It's extremely difficult to ensure that the class's definition is in fact covariant. It is much easier for the compiler to ensure that the interface is in fact covariant. With a class, simply having a field

Covariance in C# generic class

◇◆丶佛笑我妖孽 提交于 2019-12-02 01:03:16
问题 C# 4.0 .NET 4.5 Silverlight 5 It seems weird that I cant find the solution so need some help please. I have base class Base and derived class Child : Base. I have also helper class which has generic type to do specific work one EF entities Helper where T : EntityObject. Child does specific work with a specific entity MyEntity : EntityObject. So I tried: public class Base { protected Helper<EntityObject> helper; } public class Child : Base { public Child() { helper = new Helper<MyEntity>(); }

Why doesn't the example compile, aka how does (co-, contra-, and in-) variance work?

痴心易碎 提交于 2019-12-01 22:53:46
Following on from this question , can someone explain the following in Scala: class Slot[+T] (var some: T) { // DOES NOT COMPILE // "COVARIANT parameter in CONTRAVARIANT position" } I understand the distinction between +T and T in the type declaration (it compiles if I use T ). But then how does one actually write a class which is covariant in its type parameter without resorting to creating the thing unparametrized ? How can I ensure that the following can only be created with an instance of T ? class Slot[+T] (var some: Object){ def get() = { some.asInstanceOf[T] } } EDIT - now got this down

Covariance in C# generic class

喜你入骨 提交于 2019-12-01 22:36:22
C# 4.0 .NET 4.5 Silverlight 5 It seems weird that I cant find the solution so need some help please. I have base class Base and derived class Child : Base. I have also helper class which has generic type to do specific work one EF entities Helper where T : EntityObject. Child does specific work with a specific entity MyEntity : EntityObject. So I tried: public class Base { protected Helper<EntityObject> helper; } public class Child : Base { public Child() { helper = new Helper<MyEntity>(); } } I would expect that more derived class must know about more specific generic parameter and I think

Entity Framework: ObjectSet and its (generics) variance

安稳与你 提交于 2019-12-01 21:25:08
问题 I use: EntityFramework + POCO Here is the thing: public interface IBaseType { int Id { get; set; } } public class BaseType : IBaseType { public virtual int Id { get; set; } } public class DerivedType : BaseType { } The problem: public class EntityFetcher<T> where T : BaseType { public object GetById(int id) { ObjectSet<T> objectSet = (ObjectSet<T>)GetTheObjectSet(typeof(T)); return objectSet.SingleOrDefault((o) => o.Id == id); } } If T is BaseType this all works perfectly, but: The problem is

java cast from List<B> to List<A> where B extends A

爷,独闯天下 提交于 2019-12-01 21:02:38
问题 is this possible? if not, why isn't this possible in Java? interface B extends A {} public List<B> getList(); List<A> = getList(); // Type mismatch: cannot convert from List<B> to List<A> I think the topic I'm looking for is "covariant types" as here and here, but its murky and it doesn't solve my problem. 回答1: Here is an intuitive example of how this can make things go horribly wrong: interface B extends A {} List<B> blist=new List<B>(); List<A> alist=blist; alist.add(new A()); //should be

Fill lower matrix with vector by row, not column

放肆的年华 提交于 2019-12-01 20:45:47
问题 I am trying to read in a variance-covariance matrix written out by LISREL in the following format in a plain text, whitespace separated file: 0.23675E+01 0.86752E+00 0.28675E+01 -0.36190E+00 -0.36190E+00 0.25381E+01 -0.32571E+00 -0.32571E+00 0.84425E+00 0.25598E+01 -0.37680E+00 -0.37680E+00 0.53136E+00 0.47822E+00 0.21120E+01 -0.37680E+00 -0.37680E+00 0.53136E+00 0.47822E+00 0.91200E+00 0.21120E+01 This is actually a lower diagonal matrix (including diagonal): 0.23675E+01 0.86752E+00 0.28675E