locked
Logistic transform of a multivariate normal RRS feed

  • Question

  • I want to try out an extension of the StudentSkills tutorial but I am having trouble coding up what I want. I want to add a multivariate normal distribution (of dimension equal to number of skills) for each student (so something like theta[student][skill]) and make the hasSkillVar[student][skill] be a logistic function of theta[student][skill].

    In the StudentSkills tutorial we have (leaving out irrelevant snippets)

    VariableArray<double> slipVar, guessVar, pSkillVar;
    VariableArray<VariableArray<bool>, bool[][]> hasSkillVar;
    
    Range student = new Range(num_students);
    Range question = new Range(num_items);
    Range skill = new Range(num_skills);
    
    pSkillVar = Variable.Array<double>(skill).Named("pSkill");
    pSkillVar[skill] = Variable.Beta(1, 1).ForEach(skill);
    
    hasSkillVar[student][skill] = Variable.Bernoulli(pSkillVar[skill]).ForEach(student);

    I want to do something like this but its not right:

    VariableArray<Vector> abilityVar;
    abilityVar = Variable.Array<Vector>(student).Named("ability");
    abilityVar[student] = Variable.VectorGaussianFromMeanAndPrecision(
                    Vector.Zero(num_skills), PositiveDefiniteMatrix.Identity(num_skills)).ForEach(student);
    
    
    using (Variable.ForEach(student))
    {
      using (Variable.ForEach(skill))
      {
        hasSkillVar[student][skill] = Variable.Bernoulli(Variable.Logistic(Variable.GetItem(abilityVar[student], skill)));
      }
    }

    skill is a range not an int. 


    • Edited by cyentist Friday, September 8, 2017 4:58 PM
    Friday, September 8, 2017 4:51 PM

Answers

  • I figured it out with "Accessing Loop Counters" http://infernet.azurewebsites.net/docs/ForEach%20blocks.aspx
    • Marked as answer by cyentist Tuesday, September 12, 2017 6:08 PM
    Friday, September 8, 2017 5:02 PM