Special devices can be fixed on the base of the penis at bed time to monitor whether or not an erection has happened during sleep. If that test shows that an erection has happened, there is a good chance that the condition could be caused by psychological factors.