This is the Creature of Habit Cluster Analysis Using Graph Theory
#libraries needed
library(magrittr)
library(dplyr)
library(tidyr)
library(tidyverse)
library(factoextra)
library(ggpubr)
library(ggrepel)
library(fpc)
library(igraph)
library(network)
library(randomNames)
library(statnet)
library(mokken)
library(sirt)
library(psych)
library(cluster)
library(psych) ##factor analysis and other functions
library(tidytext) ##sentiment analysis package
library(cluster)
library(lavaan) ##latent variable analysis
library(semPlot) ## path diagrams and visual analysis of various SEM packages' output
library(kableExtra) ## construct complex table with 'kable' and pipe syntax
library(GGally) ## extension to GGPlot
library(stringr)
library(DiagrammeR)
Attaching package: ‘DiagrammeR’
The following object is masked from ‘package:igraph’:
count_automorphisms
library(OpenMX) ## extended structural equation modeling
Error in library(OpenMX) : there is no package called ‘OpenMX’
creaturedataALL <- read.csv("~/Library/CloudStorage/OneDrive-ProcterandGamble/2024 Files/Habit Formation/Habit Strength Measurement/habit strength data/creature of habit/creature of habit.csv")
creaturedataALL <- na.omit(creaturedataALL)
creaturedemies <- creaturedataALL[1:7]
colnames(creaturedemies)
[1] "Response.ID" "Gender" "Age.Ranges" "Household.Income" "Hispanic.Origin" "Race"
[7] "Region"
library(dplyr)
creatclustRAW <- creaturedataALL[8:67] %>%
dplyr::mutate_all(~ stringr::str_replace(., "^$", NA_character_)) %>%
dplyr::mutate_all(
.funs = ~ as.numeric (recode(
.x = .,
"Strongly Agree" = 7,
"Somewhat Agree" = 6,
"Agree" = 5,
"Neither Agree Nor Disagree" = 4,
"Disagree" = 3,
"Somewhat Disagree" = 2,
"Strongly Disagree" = 1,
))
)
creathabitq <- colnames(creatcore)
library(igraph)
Attaching package: ‘igraph’
The following objects are masked from ‘package:dplyr’:
as_data_frame, groups, union
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
network <- graph_from_data_frame(creatclustRAW)
plot(network)
Number of Clusters in Network
clusters <- igraph::degree(network)
print(clusters)
6 4 3 7 5 1 2
166 159 61 132 172 47 63
Cluster Definitions
cluster_def <- make_neighborhood_graph(network)
print(cluster_def)
[[1]]
IGRAPH d016e4f DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from d016e4f (vertex names):
[[2]]
IGRAPH 6ca46d5 DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from 6ca46d5 (vertex names):
[[3]]
IGRAPH 1af87bd DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from 1af87bd (vertex names):
[[4]]
IGRAPH 0f99627 DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from 0f99627 (vertex names):
[[5]]
IGRAPH 4e9a602 DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from 4e9a602 (vertex names):
[[6]]
IGRAPH 7c52380 DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from 7c52380 (vertex names):
[[7]]
IGRAPH 30cf8fe DN-- 7 400 --
+ attr: name (v/c), I.tend.to.go.to.bed.at.roughly.the.same.time.every.night. (e/n),
| I.cannot.stand.leaving.things.unfinished. (e/n), I.usually.exercise.at.the.same.time.of.day. (e/n),
| I.wake.up.at.roughly.the.same.time.every.day..even.without.the.help.of.an.alarm.clock. (e/n),
| I.tend.to.do.things.in.the.same.order.every.morning..e.g..get.up..go.to.the.toilet..have.a.coffee...
| (e/n),
| I.often.find.myself.running.on..autopilot...and.then.wonder.why.I.ended.up.in.a.particular.place.or.doing.something.that.I.did.not.intend.to.do.
| (e/n), I.always.try.to.get.the.same.seat.in.places.such.as.on.the.bus..in.the.cinema..or.in.church. (e/n),
| I.have.a.nightly.wind.down.routine.that.helps.me.to.fall.asleep.more.easily. (e/n),
| I.get.annoyed.by.people.who.open.a.new.packet.of.food.or.bottle.of.drink..e.g..milk..before.the.old.one.is.finished.
| (e/n), I.have.a.favorite.mug.for.my.tea.coffee. (e/n),
| I.rely.on.what.is.tried.and.tested.rather.than.exploring.something.new. (e/n),
| I.generally.keep.a.spare.set.of.things.such.as.batteries.that.I.can.fall.back.on..if.needed.. (e/n),
| Although.sometimes.tempted.to.go.for.special.offers..I.generally.buy.household.brands.that.I.can.trust..
| (e/n), I.tend.to.like.routine. (e/n), I.hate.it.when.the.grocery.store.rearranges.the.aisles. (e/n),
| If.I.could..I.would.probably.always.pick.the.same.outfit.to.wear.every.day.. (e/n),
| I.am.one.of.those.people.who.get.really.annoyed.by.last.minute.cancellations. (e/n),
| I.haven.t.bothered.to.change.my.hairstyle.for.several.years. (e/n), I.hate.being.late.for.anything. (e/n),
| I.generally.put.my.phone.on.charge.even.when.it.is.more.than.half.full. (e/n),
| I.regularly.tidy.up.my.workspace. (e/n),
| I.tend.to.stick.with.the.version.of.the.software.package.that.I.am.familiar.with.for.as.long.as.I.can.
| (e/n), I.quite.happily.work.within.my.comfort.zone.rather.than.challenging.myself..if.I.don.t.have.to..
| (e/n), If.I.can..I.like.to.give.exact.change.at.the.checkout.. (e/n), I.find.comfort.in.regularity. (e/n),
| I.always.tend.to.visit.the.same.websites.when.browsing.the.internet. (e/n),
| I.like.to.revisit.places.where.I.have.been.before. (e/n), I.am.prone.to.eating.more.when.I.feel.stressed.
| (e/n), I.have.a.preferred.sandwich.that.I.always.pick. (e/n),
| In.a.restaurant..I.tend.to.order.dishes.that.I.am.familiar.with. (e/n),
| I.tend.to.plan.meals.days.in.advance. (e/n),
| I.usually.eat.at.certain.times.of.the.day..even.when.I.am.on.holiday.. (e/n),
| I.like.to.finish.meals.either.with.something.sweet.or.something.savory. (e/n),
| I.always.lick.the.lid.of.a.yogurt. (e/n), I.typically.eat.the.best.part.of.the.meal.at.the.end. (e/n),
| I.often.find.myself.finishing.off.a.packet.of.biscuits.just.because.it.is.lying.there. (e/n),
| I.quickly.get.bored.of.preparing.the.same.dishes.over.and.over.again. (e/n),
| I.often.find.myself.opening.up.the.cabinet.to.take.a.snack. (e/n),
| When.walking.past.a.plate.of.sweets.or.biscuits..I.can.t.resist.taking.one.. (e/n),
| I.tend.to.cook.more.than.I.can.eat. (e/n), I.usually.sit.at.the.same.place.at.the.dinner.table. (e/n),
| I.usually.treat.myself.to.a.snack.at.the.end.of.the.workday. (e/n),
| I.generally.cook.with.the.same.spices.flavorings. (e/n),
| I.always.follow.a.certain.order.when.preparing.a.meal. (e/n),
| Whenever.I.go.into.the.kitchen..I.typically.look.in.the.fridge.. (e/n),
| I.like.to.eat.some.foods.in.a.certain.way..e.g..I.eat.the.pizza.crust.first.or.cut.up.all.the.meat.on.the.plate.in.one.go..
| (e/n), I.always.add.salt.before.tasting.food. (e/n),
| When.I.come.home..I.often.have.no.idea.what.to.have.for.dinner.. (e/n), I.only.eat.when.I.am.hungry.
| (e/n), I.always.need.something.to.drink.with.a.meal. (e/n),
| Eating.snacks.like.chips.straight.out.of.the.packet.is.typical.of.me. (e/n),
| It.feels.odd.not.having.both.a.knife.and.fork.for.eating.meals. (e/n),
| Television.makes.me.particularly.prone.to.uncontrolled.eating. (e/n),
| I.often.find.myself.eating.without.being.aware.of.it. (e/n),
| I.normally.buy.the.same.foods.from.the.same.grocery.store. (e/n),
| Finishing.everything.on.my.plate.is.typical.of.me. (e/n),
| I.often.take.a.snack.while.on.the.go..e.g..when.driving..walking.down.the.street..or.surfing.the.web...
| (e/n), Rout.v.Habit.Reactions.score (e/n)
+ edges from 30cf8fe (vertex names):
Adjacency Matrix
adjacency <- as_adjacency_matrix(network,
type = c("both", "upper", "lower"),
attr = NULL,
edges = FALSE,
names = TRUE,
sparse = igraph_opt("sparsematrices"))
print(adjacency)
7 x 7 sparse Matrix of class "dgCMatrix"
6 4 3 7 5 1 2
6 23 14 9 4 18 4 9
4 26 24 10 3 9 7 9
3 2 5 4 . 2 3 2
7 10 9 3 31 13 6 10
5 22 13 15 11 27 5 8
1 . 3 1 1 . 6 2
2 2 3 1 . 2 3 6
Factor Analysis–7 factor solution
library(psych)
colnames(creatclustRAW) <- c("COHS1","COHS2", "COHS3", "COHS4", "COHS5", "COHS6", "COHS7", "COHS8", "COHS9", "COHS10", "COHS11", "COHS-2", "COHS13", "COHS14", "COHS15", "COHS16", "COHS17", "COHS18", "COHS19", "COHS20", "COHS21", "COHS22", "COHS23", "COHS24", "COHS25", "COHS26", "COHS27", "COHS28", "COHS29", "COHSF1", "COHSF2", "COHSF3", "COHSF4", "COHSF5", "COHSF6", "COHSF7", "COHSF8", "COHSF9", "COHSF10", "COHSF11", "COHSF12", "COHSF13", "COHSF14", "COHSF15", "COHSF16", "COHSF17", "COHSF18", "COHSF19", "COHSF20", "COHSF21", "COHSF22", "COHSF23", "COHSF24", "COHSF25", "COHSF26", "COHSF27", "COHSF28", "COHSF29", "COHSF30")
creatclustRAW_Scaled <- scale(creatclustRAW)
fa <- fa(r = creatclustRAW_Scaled, nfactors = 7, rotate ="Varimax")
Loading required namespace: GPArotation
summary(fa)
Factor analysis with Call: fa(r = creatclustRAW_Scaled, nfactors = 7, rotate = "Varimax")
Test of the hypothesis that 7 factors are sufficient.
The degrees of freedom for the model is 1319 and the objective function was 5.03
The number of observations was 400 with Chi Square = 1878.89 with prob < 2.1e-22
The root mean square of the residuals (RMSA) is 0.04
The df corrected root mean square of the residuals is 0.04
Tucker Lewis Index of factoring reliability = 0.858
RMSEA index = 0.032 and the 10 % confidence intervals are 0.029 0.036
BIC = -6023.86
fa$loadings
Loadings:
MR2 MR1 MR3 MR6 MR4 MR5 MR7
COHS1 0.249 0.420
COHS2 0.193 0.380 -0.114 0.171
COHS3 0.636 0.163
COHS4 0.119 0.192 0.294 0.274 0.233
COHS5 0.427 0.229
COHS6 0.633
COHS7 0.197 0.578 0.175
COHS8 0.397 0.244 0.261
COHS9 0.245 0.104 0.245 0.345 0.127 0.100
COHS10 0.168 0.395 0.236
COHS11 0.152 0.161 0.311 0.301 0.205
COHS-2 0.227 0.336 0.109 0.176 0.261
COHS13 0.101 0.349 0.231 0.396
COHS14 0.118 0.336 0.319 0.152
COHS15 0.309 0.228 0.280 0.129 0.205
COHS16 0.290 0.399 0.245 0.135
COHS17 0.412 0.237 0.134 0.167 -0.262
COHS18 0.232 -0.102 0.513 0.147
COHS19 0.184 0.250 0.133 0.222 0.232
COHS20 0.197 0.173 0.511
COHS21 0.122 0.162 0.505 0.118
COHS22 0.165 0.125 0.123 0.221 0.191 0.138
COHS23 0.352 0.310 -0.112 0.292
COHS24 0.345 0.213 0.111 0.244 0.124 -0.190
COHS25 0.445 0.388
COHS26 0.120 0.236 0.123 0.290 0.255
COHS27 0.410 0.201 0.354 0.139 -0.136
COHS28 0.123 0.392 0.153 0.157 0.254
COHS29 0.388 0.108 0.259 0.130 0.164 0.160
COHSF1 0.517 0.116 -0.299
COHSF2 0.287 0.384 0.134 0.119
COHSF3 0.109 0.651
COHSF4 0.203 0.114 0.187 0.117 0.419
COHSF5 0.132 0.280 0.263 0.162 0.265 0.117
COHSF6 0.227 0.297 0.159 0.202 0.144
COHSF7 0.293 0.101 0.344
COHSF8 0.338 0.133 0.400
COHSF9 0.495 0.110 0.193 0.126 0.220
COHSF10 0.392 0.254 -0.118
COHSF11 0.549 0.204 0.232 -0.135
COHSF12 0.578 0.346 0.122
COHSF13 0.542 0.141 -0.110
COHSF14 0.122 0.204 0.424 0.140
COHSF15 0.420 0.304 0.103 0.133 0.154 0.128
COHSF16 0.196 0.590 0.148 0.181
COHSF17 0.222 0.341 0.282 0.209 0.183
COHSF18 0.558 0.387 0.103 0.145
COHSF19 0.339 0.254 0.267
COHSF20 0.448 -0.143 0.354
COHSF21 0.399 0.129 -0.130
COHSF22 -0.157 0.133 0.489
COHSF23 0.187 0.368 -0.103
COHSF24 0.338 0.242 0.287
COHSF25 0.279 0.317 -0.124
COHSF26 0.642 -0.117 0.100
COHSF27 0.667 -0.172 0.118
COHSF28 0.193 0.484 0.184
COHSF29 0.273 0.218 0.277
COHSF30 0.526 0.109 0.139 0.145 0.139
MR2 MR1 MR3 MR6 MR4 MR5 MR7
SS loadings 4.966 3.975 3.498 1.844 1.816 1.586 1.012
Proportion Var 0.084 0.067 0.059 0.031 0.031 0.027 0.017
Cumulative Var 0.084 0.152 0.211 0.242 0.273 0.300 0.317
Different Rotation
fa2 <- fa(r=creatclustRAW_Scaled, nfactors=7, rotate="oblimin")
print(fa2)
Factor Analysis using method = minres
Call: fa(r = creatclustRAW_Scaled, nfactors = 7, rotate = "oblimin")
Standardized loadings (pattern matrix) based upon correlation matrix
MR1 MR2 MR3 MR4 MR6 MR7 MR5
SS loadings 3.79 3.45 3.34 2.39 2.37 1.78 1.57
Proportion Var 0.06 0.06 0.06 0.04 0.04 0.03 0.03
Cumulative Var 0.06 0.12 0.18 0.22 0.26 0.29 0.32
Proportion Explained 0.20 0.18 0.18 0.13 0.13 0.10 0.08
Cumulative Proportion 0.20 0.39 0.57 0.69 0.82 0.92 1.00
With factor correlations of
MR1 MR2 MR3 MR4 MR6 MR7 MR5
MR1 1.00 0.30 0.24 0.34 0.37 0.20 0.07
MR2 0.30 1.00 0.08 0.14 0.10 0.38 -0.06
MR3 0.24 0.08 1.00 0.24 0.24 0.06 0.20
MR4 0.34 0.14 0.24 1.00 0.13 0.06 0.11
MR6 0.37 0.10 0.24 0.13 1.00 0.09 0.06
MR7 0.20 0.38 0.06 0.06 0.09 1.00 0.00
MR5 0.07 -0.06 0.20 0.11 0.06 0.00 1.00
Mean item complexity = 2.4
Test of the hypothesis that 7 factors are sufficient.
df null model = 1711 with the objective function = 18.29 with Chi Square = 6922.95
df of the model are 1319 and the objective function was 5.03
The root mean square of the residuals (RMSR) is 0.04
The df corrected root mean square of the residuals is 0.04
The harmonic n.obs is 400 with the empirical chi square 1789.61 with prob < 6.8e-17
The total n.obs was 400 with Likelihood Chi Square = 1878.89 with prob < 2.1e-22
Tucker Lewis Index of factoring reliability = 0.858
RMSEA index = 0.032 and the 90 % confidence intervals are 0.029 0.036
BIC = -6023.86
Fit based upon off diagonal values = 0.96
Measures of factor score adequacy
MR1 MR2 MR3 MR4 MR6 MR7 MR5
Correlation of (regression) scores with factors 0.91 0.91 0.90 0.86 0.86 0.83 0.83
Multiple R square of scores with factors 0.83 0.83 0.82 0.74 0.74 0.69 0.68
Minimum correlation of possible factor scores 0.66 0.66 0.63 0.49 0.47 0.39 0.37
Mutli-Dimensional Scaling
mds_creatclustRAW <- cmdscale((dist(creatclustRAW[,-c(1,1)])))
plot(mds_creatclustRAW[, 1], mds_creatclustRAW[, 2],
type = "n", xlab = "MDS Dimension 1",
ylab = "MDS Dimension 2")
points(mds_creatclustRAW[, 1], mds_creatclustRAW[, 2],
pch = 21, bg = "lightgray")
labels <- c("COHS1","COHS2", "COHS3", "COHS4", "COHS5", "COHS6", "COHS7", "COHS8", "COHS9", "COHS10", "COHS11", "COHS-2", "COHS13", "COHS14", "COHS15", "COHS16", "COHS17", "COHS18", "COHS19", "COHS20", "COHS21", "COHS22", "COHS23", "COHS24", "COHS25", "COHS26", "COHS27", "COHS28", "COHS29", "COHSF1", "COHSF2", "COHSF3", "COHSF4", "COHSF5", "COHSF6", "COHSF7", "COHSF8", "COHSF9", "COHSF10", "COHSF11", "COHSF12", "COHSF13", "COHSF14", "COHSF15", "COHSF16", "COHSF17", "COHSF18", "COHSF19", "COHSF20", "COHSF21", "COHSF22", "COHSF23", "COHSF24", "COHSF25", "COHSF26", "COHSF27", "COHSF28", "COHSF29", "COHSF30")
text(mds_creatclustRAW[, 1], mds_creatclustRAW[, 2],
labels = labels[-1],
pos = 3, cex = 0.6)
kmeans_clusters <- kmeans(mds_creatclustRAW, centers=7)$cluster
points(mds_creatclustRAW[, 1], mds_creatclustRAW[, 2],
pch = c(21, 22, 23, 24, 25, 3, 8), bg = kmeans_clusters, cex = 1.2)
fa3 <- fa(r=creatclustRAW_Scaled, nfactors=2, rotate="oblimin")
print(fa3)
Factor Analysis using method = minres
Call: fa(r = creatclustRAW_Scaled, nfactors = 2, rotate = "oblimin")
Standardized loadings (pattern matrix) based upon correlation matrix
MR1 MR2
SS loadings 7.04 5.46
Proportion Var 0.12 0.09
Cumulative Var 0.12 0.21
Proportion Explained 0.56 0.44
Cumulative Proportion 0.56 1.00
With factor correlations of
MR1 MR2
MR1 1.00 0.32
MR2 0.32 1.00
Mean item complexity = 1.2
Test of the hypothesis that 2 factors are sufficient.
df null model = 1711 with the objective function = 18.29 with Chi Square = 6922.95
df of the model are 1594 and the objective function was 8.19
The root mean square of the residuals (RMSR) is 0.06
The df corrected root mean square of the residuals is 0.06
The harmonic n.obs is 400 with the empirical chi square 4596.98 with prob < 2.5e-288
The total n.obs was 400 with Likelihood Chi Square = 3090.43 with prob < 2.5e-98
Tucker Lewis Index of factoring reliability = 0.69
RMSEA index = 0.048 and the 90 % confidence intervals are 0.046 0.051
BIC = -6459.96
Fit based upon off diagonal values = 0.89
Measures of factor score adequacy
MR1 MR2
Correlation of (regression) scores with factors 0.95 0.94
Multiple R square of scores with factors 0.90 0.88
Minimum correlation of possible factor scores 0.79 0.76
Functions needed to relate to the column names in the file/dataframe
##model <- '
##MR1 ~ park2 + cookspice46 + bed4 + comfortz26 + sameorder8 + seatsame10 + samefood58 + triedtrue14 + eatsame3 + likerout17 + sameorderrest33 + cancelannoy20 + seatsame44 + ordermeal47
##MR2 ~ eatsweet42 + eatongo60 + snacks54 + fridge48 + finish39 + snacktreat45 + eatunaware57 + autopilot9'
##MR1 <- creatclustRAWscaled_DF$park2 + creatclustRAWscaled_DF$cookspice46 + creatclustRAWscaled_DF$bed4 + creatclustRAWscaled_DF$comfortz26 + creatclustRAWscaled_DF$sameorder8 + creatclustRAWscaled_DF$seatsame10 + creatclustRAWscaled_DF$samefood58 + creatclustRAWscaled_DF$triedtrue14 + creatclustRAWscaled_DF$eatsame3 + creatclustRAWscaled_DF$likerout17 + creatclustRAWscaled_DF$sameorderrest33 + creatclustRAWscaled_DF$cancelannoy20 + creatclustRAWscaled_DF$seatsame44 + creatclustRAWscaled_DF$ordermeal47
##MR2<-creatclustRAWscaled_DF$eatsweet42 + creatclustRAWscaled_DF$eatongo60 + creatclustRAWscaled_DF$snacks54 + creatclustRAWscaled_DF$fridge48 + creatclustRAWscaled_DF$finish39 + creatclustRAWscaled_DF$snacktreat45 + creatclustRAWscaled_DF$eatunaware57 + creatclustRAWscaled_DF$autopilot9
##creatclustRAWscaled_DF$MR1 <- MR1
##creatclustRAWscaled_DF$MR2 <- MR2
Converting column labels to align with the original paper
df_creatclustRAW_Scaled <- as.data.frame(creatclustRAW_Scaled)
Routine <- df_creatclustRAW_Scaled$COHS1 + df_creatclustRAW_Scaled$COHSF16 + df_creatclustRAW_Scaled$COHS3 + df_creatclustRAW_Scaled$COHS25 + df_creatclustRAW_Scaled$COHS7 + df_creatclustRAW_Scaled$COHS9 + df_creatclustRAW_Scaled$COHSF28 + df_creatclustRAW_Scaled$COHS13 + df_creatclustRAW_Scaled$COHS2 + df_creatclustRAW_Scaled$COHS16 + df_creatclustRAW_Scaled$COHSF3 + df_creatclustRAW_Scaled$COHS19 + df_creatclustRAW_Scaled$COHSF14 + df_creatclustRAW_Scaled$COHSF17
Automaticity <- df_creatclustRAW_Scaled$COHSF12 + df_creatclustRAW_Scaled$COHSF30 + df_creatclustRAW_Scaled$COHSF24 + df_creatclustRAW_Scaled$COHSF18 + df_creatclustRAW_Scaled$COHSF9 + df_creatclustRAW_Scaled$COHSF15 + df_creatclustRAW_Scaled$COHSF27 + df_creatclustRAW_Scaled$COHS8
model <- '
Routine ~ COHS1 + COHSF16 + COHS3 + COHS25 + COHS7 + COHS9 + COHSF28 + COHS13 + COHS2 + COHS16 + COHSF3 + COHS19 + COHSF14 + COHSF17
Automaticity ~ COHSF12 + COHSF30 + COHSF24 + COHSF18 + COHSF9 + COHSF15 + COHSF27 + COHS8
'
Creating the SEM diagram. Adding two columns–Routine & Automaticity
library(lavaan)
df_creatclustRAW_Scaled$Routine <- df_creatclustRAW_Scaled$COHS1 + df_creatclustRAW_Scaled$COHSF16 + df_creatclustRAW_Scaled$COHS3 + df_creatclustRAW_Scaled$COHS25 + df_creatclustRAW_Scaled$COHS7 + df_creatclustRAW_Scaled$COHS9 + df_creatclustRAW_Scaled$COHSF28 + df_creatclustRAW_Scaled$COHS13 + df_creatclustRAW_Scaled$COHS2 + df_creatclustRAW_Scaled$COHS16 + df_creatclustRAW_Scaled$COHSF3 + df_creatclustRAW_Scaled$COHS19 + df_creatclustRAW_Scaled$COHSF14 + df_creatclustRAW_Scaled$COHSF17
df_creatclustRAW_Scaled$Automaticity <- df_creatclustRAW_Scaled$COHSF12 + df_creatclustRAW_Scaled$COHSF30 + df_creatclustRAW_Scaled$COHSF24 + df_creatclustRAW_Scaled$COHSF18 + df_creatclustRAW_Scaled$COHSF9 + df_creatclustRAW_Scaled$COHSF15 + df_creatclustRAW_Scaled$COHSF27 + df_creatclustRAW_Scaled$COHS8
fit<-cfa(model, data=df_creatclustRAW_Scaled)
Warning: lavaan->lav_samplestats_icov():
sample covariance matrix is not positive-definite
Warning: lavaan->lav_lavaan_step11_estoptim():
Model estimation FAILED! Returning starting values.
summary(fit, fit.measures = TRUE, standardized=T, rsquare=T)
Warning: lavaan->lav_object_summary():
fit measures not available if model did not converge
lavaan 0.6-18 did NOT end normally after 290 iterations
** WARNING ** Estimates below are most likely unreliable
Estimator ML
Optimization method NLMINB
Number of model parameters 25
Number of observations 400
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
Routine ~
COHS1 1.000 NA 1.000 0.136
COHSF16 1.000 NA 1.000 0.136
COHS3 1.000 NA 1.000 0.136
COHS25 1.000 NA 1.000 0.136
COHS7 1.000 NA 1.000 0.136
COHS9 1.000 NA 1.000 0.136
COHSF28 1.000 NA 1.000 0.136
COHS13 1.000 NA 1.000 0.136
COHS2 1.000 NA 1.000 0.136
COHS16 1.000 NA 1.000 0.136
COHSF3 1.000 NA 1.000 0.136
COHS19 1.000 NA 1.000 0.136
COHSF14 1.000 NA 1.000 0.136
COHSF17 1.000 NA 1.000 0.136
Automaticity ~
COHSF12 1.027 NA 1.027 0.199
COHSF30 1.018 NA 1.018 0.198
COHSF24 1.051 NA 1.051 0.204
COHSF18 1.035 NA 1.035 0.201
COHSF9 1.000 NA 1.000 0.194
COHSF15 1.034 NA 1.034 0.201
COHSF27 1.033 NA 1.033 0.201
COHS8 1.045 NA 1.045 0.203
Covariances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.Routine ~~
.Automaticity -0.001 NA -0.001 -0.799
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.Routine 0.000 NA 0.000 0.000
.Automaticity 0.791 NA 0.791 0.030
R-Square:
Estimate
Routine 1.000
Automaticity 0.970
Another option
library(semPlot)
semPaths(fit, 'std', layout = 'circle2')
Another option
semPaths(fit, 'std', layout = 'circle2', edge.label.cex = 0.8, residuals = FALSE, sizeMAn = 7, intercepts=FALSE, title=FALSE, exoVar = FALSE, exoCov = FALSE, posCol=c("skyblue4", "darkred"))
Warning in qgraph::qgraph(Edgelist, labels = nLab, bidirectional = Bidir, :
The following arguments are not documented and likely not arguments of qgraph and thus ignored: sizeMAn
Another option
semPaths(fit, whatLabels="std", title=FALSE, nCharNodes=0, sizeMan = 4, node.width = 1.2, edge.label.cex = 0.75, rotation= 3, style = "ram", mar = c(5, 5, 5, 5), exoVar = FALSE, exoCov = FALSE, layout='circle2', edge.color="darkblue")
Trying to use DiagrameR but having trouble finding the combine_nodes function.
library(magrittr)
library(lavaan)
library(psych)
library(semPlot)
library(dplyr)
library(DiagrammeR)
fit2 %>% parameterestimates %>% sample_n(5)
paths <- fit2 %>%
parameterestimates %>%
dplyr::select(lhs, op, rhs, est)
latent <- paths %>%
filter(op == "=~") %>%
dplyr::select(nodes = lhs) %>%
distinct %>%
dplyr::mutate(shape = "circle")
`%not_in%` <- Negate(`%in%`)
manifest <- paths %>%
filter(op != "~1", lhs %not_in% latent$nodes) %>%
dplyr::select(nodes = lhs) %>%
distinct %>%
dplyr::mutate(shape = "square")
node_set <- combine_ndfs(latent, manifest)
node_set
all_paths <- paths %>%
filter(op != "~1") %>%
mutate(label = round(est, 2)) %>%
select(-est)
# Factor loadings are the paths in the "=~" lines
loadings <- all_paths %>%
filter(op == "=~") %>%
mutate(edge_from = lhs, edge_to = rhs, style = "dashed") %>%
select(edge_from, edge_to, style, label)
# This is now an edge dataframe
loadings
NA